#include<cstdio>
#include<algorithm>
#include<numeric>
using namespace std;
int main(){

  int n,t[10001];
  scanf("%d",&n);

  while(n != 0){
    for(int i=0;i<n;i++){
      scanf("%d",&t[i]);
    }
    
    sort(t,t+n);
    t[n-1] = 0;
    sort(t,t+n);
    partial_sum(t,t+n,t);
    
    printf("%d\n",accumulate(t,t+n,0));
    
    scanf("%d",&n);
  }

  return (0);
}