#include <bits/stdc++.h>
using namespace std;
bool cmp(long long a, long long b) { return a > b; }
long long n, i, a[300010], ans, sum[300010];
int main() {
  scanf("%I64d", &n);
  for (i = 1; i <= n; i++) scanf("%I64d", &a[i]);
  sort(a + 1, a + n + 1, cmp);
  for (i = 1; i <= n; i++) sum[i] = a[i] + sum[i - 1];
  for (i = n; i >= 1; i--) ans += sum[i] + a[i + 1];
  printf("%I64d\n", ans);
  return 0;
}
