#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

const int MAXN = 10010;
int jikan[MAXN];
int sum[MAXN];

int main(void) {
    int n;
    while (cin >> n) {
        if (n == 0) break;
        for (int i = 0; i < n; i++) cin >> jikan[i];
        sort(jikan, jikan+n);
        int ret = 0;
        for (int i = 1; i < n; i++) {
            sum[i] = sum[i-1] + jikan[i-1];
            ret += sum[i];
        }
        cout << ret << endl;
    }
    return 0;
}