#include <bits/stdc++.h>
using namespace std;
int n;
long long int a[500000], s = 0, ans = 0, b[50000], br, l, q, r;
void f1(long long int x) {
  r = 0;
  int i;
  while (x > 0) {
    r++;
    q = x % 10;
    x /= 10;
    l = 0;
    i = r;
    b[i] += q + l;
    if (b[i] > 9) {
      b[i] -= 10;
      l = 1;
    }
    if (l == 1) {
      while (l == 1) {
        i++;
        if (i > br) br = i;
        b[i]++;
        if (b[i] > 9) {
          b[i] -= 10;
          l = 1;
        } else
          l = 0;
      }
    }
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    s += a[i];
  }
  sort(a + 1, a + 1 + n);
  ans = s;
  while (ans != 0) {
    q = ans % 10;
    br++;
    b[br] = q;
    ans /= 10;
  }
  ans = s;
  for (int i = 1; i < n; i++) {
    f1(s);
    ans += s;
    s -= a[i];
  }
  for (int i = br; i >= 1; i--) cout << b[i];
  cout << endl;
  return 0;
}
