#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

//typedef long long ll;
typedef __int64 ll;
int n,w[10000];

int main(){
	while(cin>>n){
		if(!n)return 0;
		for(int i=0;i<n;i++)cin>>w[i];
		sort(w,w+n);
		ll ans=0;
		for(int i=0;i<n;i++)ans+=w[i]*(n-1-i);
		printf("%I64d\n",ans);/*
		printf("%d\n",ans);
		__int64 a=1;
		printf("%d\n",a);
		__int64 b=100;
		printf("%d\n",b);
		char c[]="text";
		printf("%-.2s\n",c);
		printf("%.2s\n",c);
		printf("%-s\n",c);
		printf("%s\n",c);*/
	}
}