#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int solution(vector<int> arr)
{
int answer = 0;
vector<int> temp;
sort(arr.begin(), arr.end());
for(int i=0; i < arr.size(); i++)
{
temp.push_back(arr[i]);
for(auto el : temp)
answer += el;
}
return answer;
}
int main()
{
int num, temp;
cin >> num;
vector<int> arr;
for(int i=0; i < num; i++)
{
cin >> temp;
arr.push_back(temp);
}
cout << solution(arr) << endl;
return 0;
}
음써