#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
int main()
{
int n;
cin >> n;
priority_queue<int, vector<int>, greater<int> >heap;
long long res = 0;
while(n --)
{
int a;
cin >> a;
heap.push(a);
}
while(heap.size() > 0)
{
int a = heap.top(); heap.pop();
res += a * heap.size();
}
cout << res << endl;
return 0;
}