#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main(void)
{
    int n;
    unsigned sum, wait;
    unsigned milk[10000];
    
    scanf("%d", &n);
    
    for (int i = 0; i <= n; i++){
        scanf("%d", &milk[i]);
    }
    
    sort(milk, milk + n);
    
    sum = 0;
    wait = 0;
    for (int i = 0; i < n; i++){
        sum += wait;
        wait += milk[i];
    }
    
    printf("%u\n", sum);
}