t = int(input())
for i in range(t):
    n = input()
    a = [int(x) for x in input().split()]
    j = sum(a) - min(a) * len(a)
    print(j)

233e83291ea9b8b66ef1e5ea17f88612052efa27
<mask token>

<mask token>
for i in range(t):
    n = input()
    a = [int(x) for x in input().split()]
    j = sum(a) - min(a) * len(a)
    print(j)

t = int(input())
for i in range(t):
    n = input()
    a = [int(x) for x in input().split()]
    j = sum(a) - min(a) * len(a)
    print(j)
