#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
        int n;
        int time[10000];
        int tmp;
        long long tmp_2;
        long long wait_time;

        while (1){
                scanf("%d", &n);

                if (n == 0){
                        break;
                }

                for (int i = 0; i < n; i++){
                        scanf("%d", &time[i]);
                }

                sort(time, time + n);

                wait_time = tmp_2 = 0;

                for (int i = 0; i < n - 1; i++){
                        tmp_2 += time[i];
                        wait_time += tmp_2;
                }

                printf("%lld\n", wait_time);
        }

        return (0);
}