#include <bits/stdc++.h>   using namespace std;   int main() {     int n, x;     long long score, sum = 0;     cin >> n;     vector<int> ara(n);     for (int i = 0; i < n; i++) {       cin >> ara[i];       sum += ara[i];     }     sort(ara.begin(), ara.end());     reverse(ara.begin(), ara.end());     score = sum;     for (int i = n - 1; i >= 0; i--) {       sum -= ara[i];       score += (ara[i] + sum);     }     score -= ara[0];     cout << score << endl;     return 0;   }   