#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    vector<long long> v(10000), d(10000);
    while (cin >> n, n) {
        for (int i = 0; i < n; ++i) cin >> v[i];
        sort(v.begin(), v.begin()+n);
        d[0] = 0;
        for (int i = 1; i < n; ++i) d[i] += v[i] - v[i-1];
        long long res = 0;
        for (int i = 0; i < n; ++i) res += d[i] + v[i];
        cout << res << endl;
    }
    return 0;
}