while True:



    inputCount = int(eval(input()))



    if inputCount == 0:

        break



    timeList = []



    for lp in range(inputCount):

        timeList.append(int(eval(input())))



    timeList.sort()



    totalTimeList = [0]



    for lp in range(inputCount - 1):

        waitTime = totalTimeList[-1] + timeList[lp]

        totalTimeList.append(waitTime)



    print((str(sum(totalTimeList))))



while True:



    inputCount = int(eval(input()))



    if inputCount == 0:

        break



    timeList = [int(eval(input())) for item in range(inputCount)]

    timeList.sort()



    totalTimeList = [0]



    for lp in range(inputCount - 1):

        waitTime = totalTimeList[-1] + timeList[lp]

        totalTimeList.append(waitTime)



    print((str(sum(totalTimeList))))



while True:
    inputCount = int(eval(input()))
    if inputCount == 0:
        break
    timeList = []
    for lp in range(inputCount):
        timeList.append(int(eval(input())))
    timeList.sort()
    totalTimeList = [0]
    for lp in range(inputCount - 1):
        waitTime = totalTimeList[-1] + timeList[lp]
        totalTimeList.append(waitTime)
    print((str(sum(totalTimeList))))

while True:
    inputCount = int(eval(input()))
    if inputCount == 0:
        break
    timeList = [int(eval(input())) for item in range(inputCount)]
    timeList.sort()
    totalTimeList = [0]
    for lp in range(inputCount - 1):
        waitTime = totalTimeList[-1] + timeList[lp]
        totalTimeList.append(waitTime)
    print((str(sum(totalTimeList))))

-    timeList = [] -    for lp in range(inputCount): -        timeList.append(int(eval(input()))) +    timeList = [int(eval(input())) for item in range(inputCount)]