#include <iostream>
#include <algorithm>
#include <cassert>
#include <climits>
using namespace std;

typedef long long lli;

int n;
lli a[10000];

int main() {
  while(cin >> n && n) {
    assert(1LL <= n && n <= 10000LL);
    for(int i = 0; i < n; ++i) {
      cin >> a[i];
      assert(0LL <= a[i] && a[i] <= 60LL);
    }
    sort(a, a+n);
    lli res = 0;
    for(int i = 0; i < n; ++i) {
      res += a[i] * (n-i-1);
    }
    assert(res <= INT_MAX);
    cout << res << endl;
  }
  return 0;
}