#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  int l = 0, r = n - 1;
  long long s = 0;
  while (l < r) {
    s += a[l] * (r - l) + a[r] * (r - l);
    l++;
    r--;
  }
  cout << s << "\n";
  return 0;
}
