#include<algorithm>
#include <vector>
#include <iostream>
using namespace std;
typedef long long ll;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
int n;
cin >> n;
vector<ll> time;
for (int i = 0; i < n; ++i) {
ll input;
cin >> input;
time.push_back(input);
}
sort(time.begin(), time.end());
ll sum = 0;
ll ans = 0;
for (int i = 0; i < n; ++i) {
sum += time[i];
ans += sum;
}
cout << ans;
return 0;
}