# include <iostream> using namespace std; const int maxn=100005; int n; int a[maxn]; int b[maxn]; void solve(int l, int r) { if (l==r) return ; int mid=(l+r)/2; solve(l, mid); solve(mid+1,r); int i=1,j=mid+1,k=1; while(i<=mid &&j<=r) { if (a[i]<=a[j]) b[k++]=a[i++]; else b[k++]=a[j++]; } while(i<=mid) b[k++]=a[i++]; while(j<=r) b[k++]=a[j++]; for (int i=l; i<=r; i++) a[i]=b[i]; } int main(){ cin>>n; for (int i=1; i<=n; i++) cin>>a[i]; solve(1,n); int ans=0; for (int i=1; i<=n; i++) ans=ans+a[i]*i; cout<<ans<<endl; return 0; }