#include <cstdio>
#include <queue>
using namespace std;

priority_queue < unsigned int, vector<unsigned int>, greater<unsigned int> > milk;
int n;

int main(void)
{
    int tmp;
    scanf("%d", &n);
    for (int i = 0; i <= n; i++){
        scanf("%d", &tmp);
        milk.push(tmp);
    }
    
    unsigned int sum = 0;
    unsigned int prev = 0;
    for (int i = 0; i <= n; i++){
        tmp += prev;
        sum += tmp;
        prev = milk.top();
        milk.pop();
    }
    
    printf("%d\n", sum);
    
    return (0);
}