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

using namespace std;

int main(){


	vector<unsigned int> t(10001, 61);
	unsigned int p;
	unsigned int i;
	vector<unsigned int> total(10001, 0);
	unsigned int matu = 0;


		for (i = 0; i <= 10000; i++){
			t[i] = 61;
		}
		for (i = 0; i <= 10000; i++){
			total[i] = 0;
		}
		matu = 0;

		cin >> p;
		

		for (i = 0; i < p; i++){
			cin >> t[i];
		}
		sort(t.begin(), t.begin() + i - 1);


		for (i = 1; i < p; i++){
			total[i] = t[i - 1] + total[i - 1];
		}

		for (i = 0; i < p; i++){
			matu += total[i];
		}

		cout << matu << endl;

		
	

}