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

int a[10010];
int main() {
  for (int N; scanf("%d", &N), N; ) {
      for (int i = 0; i < N; i++) {
          scanf("%d", &a[i]);
      }
      sort(a, a + N);
      long long ans = 0;
      long long acc = 0;
      for (int i = 0; i < N; i++) {
          ans += acc;
          acc += a[i];
      }
      cout << ans << endl;
  }

}