while 1:

	n = eval(input())

	if n == 0: break

	que = sorted([int(input()) for i in range(n)])

	print(sum([sum(que[:i]) for i in range(1,n)]))
while 1:

	n = eval(input())

	if n == 0: break

	q = sorted([int(input()) for i in range(n)])

	t = [0]*n

	for i in range(1,n):

		t[i] = t[i-1] + q[i-1]

	print(sum(t))
while 1:
    n = eval(input())
    if n == 0:
        break
    que = sorted([int(input()) for i in range(n)])
    print(sum([sum(que[:i]) for i in range(1, n)]))

while 1:
    n = eval(input())
    if n == 0:
        break
    q = sorted([int(input()) for i in range(n)])
    t = [0] * n
    for i in range(1, n):
        t[i] = t[i - 1] + q[i - 1]
    print(sum(t))

-    que = sorted([int(input()) for i in range(n)]) -    print(sum([sum(que[:i]) for i in range(1, n)])) +    q = sorted([int(input()) for i in range(n)]) +    t = [0] * n +    for i in range(1, n): +        t[i] = t[i - 1] + q[i - 1] +    print(sum(t))