#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  while (cin >> n, n) {
    vector<int> t(n);
    for (int i = 0; i < n; i++) {
      cin >> t[i];
    }
    sort(t.begin(), t.end());
    ll ans = 0, last = 0;
    for (int i = 0; i < n; i++) {
      ans += last;
      last += t[i];
    }
    cout << ans << endl;
  }

  return 0;
}
