#include<stdio.h>
#include<stdlib.h>
int cmp(const void* a, const void* b)
{
return (*(int*)a >= *(int*)b) ? 1:-1;
}
int main()
{
int n, i, A[1000], m, j;
int s = 0,sum = 0;
scanf("%d\n", &n);
for (i = 0; i < n; i++)
{
scanf("%d", &A[i]);
}
qsort(A, n, sizeof(int), cmp);
if (n == 1)sum = 0;
else
{
m = A[0];
j = n - 1;
s = j * m;
for (i = 1; i <n;i++,j--)
sum = sum +j * A[i];
}
printf("%d", sum + s);
return 0;
}