
import std.stdio, std.algorithm;

void main() {
  for(int times; scanf("%d", &times), times != 0;) {
    int[] arr = new int[](times);
    int ans, sum;
    foreach(i; 0..times) scanf("%d", &arr[i]);
    sort(arr);
    for(int i = 0; i < arr.length; i++) {
      ans += (times - i - 1) * arr[i];
    }
    writeln(ans);
  }
}