while True:

  n = int(eval(input()))

  if not n:

    break

  else:

    lst = [int(eval(input())) for _ in range(n)]

    lst.sort()

    acc = ans = 0

    for i in lst:

      ans += acc

      acc += i

    print(ans) 

while True:

  n = int(eval(input()))

  if not n:

    break

  lst = sorted([int(eval(input())) for _ in range(n)])

  print((sum([(n - i - 1) * lst[i] for i in range(n)])))

while True:
    n = int(eval(input()))
    if not n:
        break
    else:
        lst = [int(eval(input())) for _ in range(n)]
        lst.sort()
        acc = ans = 0
        for i in lst:
            ans += acc
            acc += i
        print(ans)

while True:
    n = int(eval(input()))
    if not n:
        break
    lst = sorted([int(eval(input())) for _ in range(n)])
    print((sum([(n - i - 1) * lst[i] for i in range(n)])))

-    else: -        lst = [int(eval(input())) for _ in range(n)] -        lst.sort() -        acc = ans = 0 -        for i in lst: -            ans += acc -            acc += i -        print(ans) +    lst = sorted([int(eval(input())) for _ in range(n)]) +    print((sum([(n - i - 1) * lst[i] for i in range(n)])))