#include <bits/stdc++.h>
using namespace std;
priority_queue<long long> q;
long long ans, sum, num;
void f() {
  long long fir;
  while (!q.empty()) {
    fir = q.top();
    fir = -fir;
    q.pop();
    ans += sum;
    sum -= fir;
    ans += fir;
  }
  ans -= fir;
  printf("%I64d\n", ans);
}
int main() {
  int n;
  scanf("%d", &n);
  {
    sum = 0;
    while (!q.empty()) q.pop();
    for (int i = 0; i < n; i++) {
      scanf("%I64d", &num);
      sum += num;
      q.push(-num);
    }
    f();
  }
  return 0;
}
