
import std.stdio, std.algorithm;

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