#include<iostream>
using namespace std;

void bubbleSort( int* a, int n )
{
    for( int i = 0; i < n; i++ )
        for( int j = 0; j < n - 1; j++ )
        {
            if( a[j] > a[j+1] )
            {
                int temp = a[j];
                a[j] = a[j+1];
                a[j+1] = temp;
            }
        }
}

int waitingMinute( int* a, int* b, int x )
{
    if( x == 0 )
        return b[0] = a[0];
    
    if( b[x] != 0 )
        return b[x];
    else
        return b[x] = a[x] + waitingMinute( a, b, x - 1 );
}

int main()
{
    int n, a[10000], sum[10000] = {0};

    while( cin >> n )
    {
        if( n == 0 )
            break;

        for( int i = 0; i < n; i++ )
        {
            cin >> a[i];
            sum[i] = 0;
        }

        bubbleSort( a, n );
        waitingMinute( a, sum, n - 1 );

        unsigned int s = 0;
        for( int i = 0; i < n - 1; i++ )
            s += sum[i];

        cout << s << endl;
    }

    return 0;
}
