#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	int n;
	while(cin>>n){
		vi d(n);
		rep(i,0,n) cin>>d[i];
		sort(all(d));
		rep(i,1,n) d[i]+=d[i-1];
		int ans=0;
		rep(i,0,n) ans+=d[i];
		o(ans);
	}
}