#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> time;
  for (int i = 0; i < n; i++){
    int tmp;
    cin >> tmp;
    time.push_back(tmp);
  }
  sort(time.begin(), time.end());
  int ans = 0;
  for (int i = 0; i < n - 1; i++){
    ans += time[i] * (n - (i + 1));
  }
  cout << ans << endl;
  return 0;
}