#include using namespace std; const int N = 100010; typedef long long LL; int a[N]; LL res; int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); for (int i = 0; i < n; i++) res += a[i] * (n - i - 1); printf("%lld", res); return 0; }