In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. 

Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in a_{i} burles (burle is the currency in Berland).

You are the royal treasurer, which needs to count the minimum charges of the kingdom on the king's present. The king can only give money, he hasn't a power to take away them. 


-----Input-----

The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom.

The second line contains n integers a_1, a_2, ..., a_{n}, where a_{i} (0 ≤ a_{i} ≤ 10^6) — the welfare of the i-th citizen.


-----Output-----

In the only line print the integer S — the minimum number of burles which are had to spend.


-----Examples-----
Input
5
0 1 2 3 4

Output
10
Input
5
1 1 0 1 1

Output
1
Input
3
1 3 1

Output
4
Input
1
12

Output
0


-----Note-----

In the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.

In the second example it is enough to give one burle to the third citizen. 

In the third example it is necessary to give two burles to the first and the third citizens to make the welfare of citizens equal 3.

In the fourth example it is possible to give nothing to everyone because all citizens have 12 burles.

Difficulty: interview

Starter code:

Solutions:
n=int(input())
a=list(map(int,input().split()))
print(n*max(a)-sum(a))


n = int(input())
a = list(map(int, input().split()))
x = max(a)
print(sum([x - a[i] for i in range(n)]))

import sys
n = int(input())
z = list(map(int, input().split()))
a = max(z) * n
print(a - sum(z))
                            
            
    


def main():
	n = int(input())
	arr = list(map(int, input().split()))
	x = max(arr)
	print(sum([x - i for i in arr]))


main()

n = int(input())
v = list(map(int, input().split()))

mx = max(v)
v = [mx-x for x in v]
print(sum(v))

n=int(input())
ip=list(map(int,input().split()))
ans=0
t=max(ip)
for i in ip:
    ans+=t-i
print(ans)


n = int(input())
a = list(map(int, input().split()))
m = max(a)
print(n * m - sum(a))

n = int(input())
arr = [int(x) for x in input().split()]
print(n*max(arr)-sum(arr))

s = input()
s = list(map(int, input().split()))
print(len(s) * max(s) - sum(s))

n = input()

a = list(map(int, input().split()))

m = max(a)
s = 0
for i in a:
    s += m - i

print(s)


n = int(input())
arr = [int(x) for x in input().split()]
m = max(arr)
ans = 0
for x in arr:
    ans += m - x
print(ans)

n = int(input())
a = list(map(int, input().split()))
print(n * max(a) - sum(a))

from sys import stdin, stdout
n = int(stdin.readline())
values = list(map(int, stdin.readline().split()))
mx = max(values)

cnt = 0
for i in range(n):
    cnt += mx - values[i]
    
stdout.write(str(cnt))

n = int(input())
a = list(map(int, input().split()))

ans = 0
m = max(a)
for elem in a:
    ans += m - elem
    
print(ans)

n=int(input())
l=[int(x) for x in input().split()]
mx=max(l)
ans=0
for e in l:
  ans+=mx-e
print(ans)
  


n = int(input())
arr = list(map(int, input().split()))
m = max(arr)
s = 0
for i in arr:
    s += m - i
print(s)

n = int(input())
a = list(map(int,input().split()))
x = max(a)
ans = 0
for i in a:
    ans += x-i
print(ans)    


n = int(input().strip())
money = list(map(int, input().split()))
m = max(money)
pay = 0
for a in money:
    pay += m - a
print(pay)

n=int(input())
v=list(map(int,input().split()))
k=max(v)
ans=0
for i in range(n):
	ans+=k-v[i]
print(ans)	

n = int(input())
a = list(map(int , input().split()))
maxim = max(a)
ans = 0
for i in range(n):
    ans += a[i] - maxim
print(-ans)

n = int(input())

a = [int(i) for i in input().split()]

m = max(a)

min_sum = 0
for elem in a:
    min_sum += m - elem

print(min_sum)

n = int(input())
A = list(map(int,input().split()))
t = max(A)
sums = 0
for j in range(n):
    sums += (t - A[j])
print(sums)

n = int(input())
a = list(map(int, input().split()))
x = max(a)
s = 0
for i in range(n):
    s += x - a[i]
print(s)


n = int(input())
v = list(map(int, input().split()))
m = max(v)
result = m * n - sum(v)
print(result)

n=int(input())
listi=[int(x) for x in input().split()]
s=0
m=max(listi)
for i in listi:
    s=s+(m-i)
print(s)