1 /*
2 贪心:每次把一个丢掉,选择最小的。累加求和,重复n-1次
3 */
4 /************************************************
5 Author :Running_Time
6 Created Time :2015-8-1 13:20:01
7 File Name :A.cpp
8 *************************************************/
9
10 #include <cstdio>
11 #include <algorithm>
12 #include <iostream>
13 #include <sstream>
14 #include <cstring>
15 #include <cmath>
16 #include <string>
17 #include <vector>
18 #include <queue>
19 #include <deque>
20 #include <stack>
21 #include <list>
22 #include <map>
23 #include <set>
24 #include <bitset>
25 #include <cstdlib>
26 #include <ctime>
27 using namespace std;
28
29 typedef long long ll;
30 const int MAXN = 3e5 + 10;
31 const int INF = 0x3f3f3f3f;
32 const int MOD = 1e9 + 7;
33 int a[MAXN];
34
35 int main(void) { //Codeforces Round #263 (Div. 2) C. Appleman and Toastman
36 int n; ll sum, ans;
37 while (scanf ("%d", &n) == 1) {
38 sum = 0;
39 for (int i=1; i<=n; ++i) {
40 scanf ("%d", &a[i]); sum += a[i];
41 }
42 if (n == 1) {
43 printf ("%d\n", a[1]); continue;
44 }
45 sort (a+1, a+1+n);
46 ans = sum;
47 for (int i=1; i<n; ++i) {
48 ans += sum; sum -= a[i];
49 }
50 printf ("%I64d\n", ans);
51 }
52
53 return 0;
54 }