#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
const int N = 1e5+10;
typedef long long LL;
int n;
int t[N]; //表示每个人的时间。
int main()
{
scanf("%d", &n);
for(int i=0;i<n;i++) scanf("%d",&t[i]);
sort(t,t+n); //按照打水时间从大到小排序。
LL res=0; //结果可能爆int。
for(int i=0;i<n;i++)
{
res +=t[i]*(n-i-1);
}
printf("%lld",res);
return 0;
}