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

int main() {
    vector<int> v;
    int n;
    while(cin >> n, n) {
      while(n--) {
	int t; cin >> t;
	v.push_back(t);
      }

      sort(v.begin(), v.end());

      int sum = 0, ans = 0;
      for(int i = 0; i < v.size(); i++) {
	ans += sum;
	sum += v[i];
      }
      cout << ans << endl;
    }
}