while 1:

  n=eval(input())

  if n==0: break

  x=sorted([eval(input()) for _ in [0]*n])

  s=0

  a=0

  for e in x[:-1]: a+=e; s+=a

  print(s)
while 1:

  n=eval(input())

  if n==0: break

  x=sorted([int(input()) for _ in [0]*n])

  s=0

  a=0

  for e in x[:-1]: a+=e; s+=a

  print(s)
while 1:
    n = eval(input())
    if n == 0:
        break
    x = sorted([eval(input()) for _ in [0] * n])
    s = 0
    a = 0
    for e in x[:-1]:
        a += e
        s += a
    print(s)

while 1:
    n = eval(input())
    if n == 0:
        break
    x = sorted([int(input()) for _ in [0] * n])
    s = 0
    a = 0
    for e in x[:-1]:
        a += e
        s += a
    print(s)

-    x = sorted([eval(input()) for _ in [0] * n]) +    x = sorted([int(input()) for _ in [0] * n])