#include <iostream>
#include <algorithm>

using namespace std;

const int N = 10000;
int a[N];

int main(){
	int n;
	while(cin >> n, n){
		int s = 0, t = 0;
		fill(a, a + N, 61);
		for(int i = 0;i < n;++i){
			cin >> a[i];
		}
		sort(a, a + N);
		for(int i = 0;i < n - 1;++i){
			t += a[i];
			s += t;
		}
		cout << s << endl;
	}
	return 0;
}