#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main(void){
	
	int i,n;
	unsigned long long sum,temp;
	
	vector<unsigned long long> cus;
	vector<unsigned long long> wait;
		
	cus.clear();
	wait.clear();
	i=sum=temp=0;
			
	cin>>n;
	
	for(int k=0;k<=n;k++){
		cin>>i;
		if(k>1000||n==0){
			break;
		}
		cus.push_back(i);
	}
	
	sort(cus.begin(),cus.end());

	for(int k=0;k<cus.size();k++){
		for(int m=0;m<k;m++){
			temp=temp+cus[m];
		}
		wait.push_back(temp);
		temp=0;
	}
	
	for(int k=0;k<wait.size();k++){
		sum=sum+wait[k];
	}
	
	cout<<sum<<endl;
}