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: EASY
Tags: Mathematics

Implementation

Starter code:

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


no = int(input())
cit = [int(x) for x in input().split()]
m = max(cit)
res = 0
for i in cit:
	res = res - i + m
print(res)


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


y = int(input())
x = list(map(int, input().split()))
if y == 1:
	print(0)
else:
	i = 0
	a = -1
	while i < y:
		if x[i] >= a:
			a = x[i]
		i += 1
	i = 0
	s = 0
	while i < len(x):
		x[i] = a - x[i]
		s += x[i]
		i += 1
	print(s)


a = int(input())
b = sorted([int(i) for i in input().split()])
c = 0
for i in range(a):
	c += b[-1] - b[i]
print(c)


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


n = int(input())
money = list(map(int, input().split()))
max_money = max(money)
count = 0
for num in money:
	count += max_money - num
print(count)


n = int(input())
a = list(map(int, input().split()))
ma = max(a)
b = []
for i in a:
	b.append(abs(ma - i))
print(sum(b))


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


a = int(input())
b = input().split()
sum = 0
n = 0
for i in range(a):
	if int(b[i]) > n:
		n = int(b[i])
for i in range(a):
	sum += n - int(b[i])
print(sum)


import sys

def main():
	_sum = 0
	n = int(input())
	a = list(map(int, input().split()))
	_max = max(a)
	for i in range(n):
		_sum += _max - a[i]
	print(_sum)
sys.exit(main())


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


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


n = int(input())
wel = [int(i) for i in input().split()]
maxwel = max(wel)
output = n * maxwel - sum(wel)
print(output)


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


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


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


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


n = int(input())
s = 0
num = sorted([int(i) for i in input().split()])
for i in range(n):
	s += num[n - 1] - num[i]
print(s)


citizens = int(input(''))
x = input('').split()
list = []
output = 0
for c in range(citizens):
	list.append(int(x[c]))
list.sort()
for c in range(citizens - 1):
	output += list[citizens - 1] - list[c]
print(output)


am = int(input())
arr = list(map(int, input().split()))
m = max(arr)
c = 0
for i in range(am):
	c += m - arr[i]
print(c)


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


n = int(input())
a = list(map(int, input().strip().split()))[:n]
a.sort()
z = [a[-1] - elem for elem in a]
print(sum(z))


n = int(input())
A = [int(a) for a in input().split()]
m = max(A)
g = sum((m - a for a in A))
print(g)


n = input()
a = [int(ai) for ai in input().split(' ')]
a.sort()
a_max = a.pop()
s = 0
for ai in a:
	s += a_max - ai
print(s)


n = input()
burles = [int(i) for i in input().split()]
add = 0
for each in burles:
	add += max(burles) - each
print(add)


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


n = int(input())
welfares = [int(w) for w in input().split()]
theMax = max(welfares)
burles = sum(welfares)
print(n * theMax - burles)


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


n = int(input())
lst = list(map(int, input().split()))
m = max(lst)
sum = 0
for i in range(len(lst)):
	if lst[i] < m:
		sum = sum + m - lst[i]
print(sum)


hm = int(input())
wel = input().split(' ')
for i in range(hm):
	wel[i] = int(wel[i])
coin = 0
for i in range(hm):
	coin += max(wel) - wel[i]
print(coin)


n = int(input())
xs = [int(x) for x in input().split()]
if n == 1:
	print(0)
else:
	m = max(xs)
	print(sum((m - x for x in xs)))


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


c = input()
a = [int(i) for i in input().split()]
b = max(a)
res = 0
for i in a:
	res += b - i
print(res)


n = int(input())
w = list(map(int, input().split()))
w.sort(reverse=True)
a = w[0]
tally = 0
for i in w:
	c = i
	if i == a:
		continue
	else:
		while a > c:
			c += 1
			tally += 1
		continue
print(tally)


people = int(input())
data = input().split(' ')
m = 0
for c in data:
	if m < int(c):
		m = int(c)
s = 0
for c in data:
	s += m - int(c)
print(s)


n = int(input())
money = [int(x) for x in input().split()]
M = max(money)
res = 0
for i in money:
	res += M - i
print(res)


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


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


x = int(input())
y = list(map(str, input().split()[:x]))
y = [int(x) for x in y]
y.sort()
e = 0
for n in range(x - 1):
	e = e + (y[x - 1] - y[n])
print(e)


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


n = int(input())
l = list(map(int, input().split()))
cnt = 0
l.sort()
max = l[len(l) - 1]
for i in range(len(l) - 1):
	cnt = cnt + abs(max - l[i])
print(cnt)


n = int(input())
h = list(map(int, input().split()))
m = max(h)
sum = 0
for i in range(n):
	sum = sum + (m - h[i])
print(sum)


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


t = int(input())
arr = input()
l = list(map(int, arr.split(' ')))
residue = 0
for num in l:
	residue += max(l) - num
print(residue)


n = int(input())
a = map(int, input().split())
mx = 0
cnt = 0
for i in a:
	mx = max(mx, i)
	cnt += i
print(mx * n - cnt)


n = int(input())
a = map(int, input().split(maxsplit=n))
s = list(a)
b = []
for i in range(n):
	c = max(s) - s[i]
	b.append(c)
print(sum(b))


_ = int(input())
tests = list(map(int, input().split()))
cost = 0
for test in tests:
	cost += max(tests) - test
print(cost)


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


input()
k = list(map(int, input().split()))
print(sum((max(k) - i for i in k)))


n = int(input())
l = input().split()
a = []
max = 0
sum = 0
for i in range(n):
	a.append(int(l[i]))
	if a[i] > max:
		max = a[i]
for i in range(n):
	sum += max - a[i]
print(sum)


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


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


n = int(input())
a = map(int, input().split())
s = 0
mx = 0
for x in a:
	s = s + x
	if x > mx:
		mx = x
print(n * mx - s)


num = int(input())
welfare = list(map(int, input().split()))
high = max(welfare)
total = sum(welfare)
payment = high * num - total
print(payment)


n = int(input())
l = [int(i) for i in input().split()]
m = l[0]
for i in range(1, n):
	if l[i] > m:
		m = l[i]
c = 0
for i in range(n):
	c += m - l[i]
print(c)


n = int(input())
a = [int(s) for s in input().split()]
m = max(a)
a.remove(m)
b = 0
for v in a:
	b += m - v
print(b)


n = int(input())
lis = list(map(int, input().split()))
track = 0
count = 0
for i in lis:
	if i > track:
		track = i
for i in lis:
	count += track - i
print(count)


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


a = int(input())
b = input().split()
c = [int(i) for i in b]
sum = 0
k = max(c)
for i in c:
	if i != k:
		sum += k - i
print(sum)


n = int(input())
a = list(map(int, input().split()))
max = 0
l = []
p = []
for i in range(n):
	if max < a[i]:
		max = a[i]
for i in range(n):
	h = max - a[i]
	l.append(h)
k = 0
for i in range(n):
	k = k + l[i]
print(k)


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


n = int(input())
lst = list(map(int, input().split(' ')))
sum_n = 0
for i in range(len(lst)):
	sum_n += max(lst) - lst[i]
print(sum_n)


n = eval(input())
data = list(map(int, input().strip().split()))
x = max(data)
s = 0
p = 0
m = 0
for i in range(n):
	d = data[i]
	m = x - d
	p = p + m
print(p)


n = int(input())
tmp = list(map(int, input().split()))
maxx = max(tmp)
sum = 0
for item in tmp:
	sum += maxx - item
print(sum)


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())
a = list(map(int, input().split()))
t = max(a)
x = 0
for i in a:
	x = x + (t - i)
print(int(x))


n = int(input())
wel = [int(x) for x in input().split()]
bul = 0
m = max(wel)
for i in range(len(wel)):
	bul += m - wel[i]
print(bul)


def myf(n, sn):
	mymax = max(sn)
	result = 0
	for i in range(n):
		result += mymax - sn[i]
	return result
n = int(input())
sn = list(map(int, input().split()))
res = myf(n, sn)
print(res)


def solve(a):
	count = 0
	for i in range(len(a)):
		if a[i] < max(a):
			count += max(a) - a[i]
	return count
n = int(input())
array = list(map(int, input().split()))
print(solve(array))


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


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


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


n = int(input())
x = [int(i) for i in input().split()]
y = max(x)
c = 0
for j in range(0, len(x)):
	if x[j] < y:
		c = c + (y - x[j])
print(c)


a = input()
b = [int(x) for x in input().split()]
a = int(a)
m = max(b)
count = 0
for i in range(0, a):
	d = 0
	if b[i] != m:
		d = m - b[i]
		count = count + d
print(count)


n = int(input())
a = [int(i) for i in input().split()]
m = max(a)
print(sum([m - e for e in a]))


n = int(input())
a = list(map(int, input().split()))
nado = 0
nadodo = max(a)
for i in a:
	if i < nadodo:
		nado += nadodo - i
print(nado)


n = int(input())
a = input().split()
for i in range(n):
	a[i] = int(a[i])
a = sorted(a)
s = 0
for i in range(n - 1):
	if a[i] < a[-1]:
		s = s + a[-1] - a[i]
print(s)


input()
a = input().split()
s = []
for i in a:
	s.append(int(i))
m = max(s)
d = 0
for i in s:
	d += m - i
print(d)


n = int(input())
mn = input()
mn = [int(i) for i in mn.strip().split()]
count = 0
mx = max(mn)
for i in mn:
	count += mx - i
print(count)


from functools import reduce
n = int(input())
a = list(map(int, input().split()))
c = 0
x = max(a)
print(x * n - reduce(lambda i, j: i + j, a))


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


o = int(input())
welfare = [int(pp) for pp in input().split()]
mex = welfare[0]
for i in range(1, o):
	mex = max(welfare[i], mex)
burl = 0
for j in range(0, o):
	burl += mex - welfare[j]
print(burl)


n = int(input())
li = [int(num) for num in input().split()]
li.sort()
l = len(li)
s = 0
x = 0
for i in range(l):
	x = li[-1] - li[i]
	s = s + x
print(s)


n = int(input())
a = input().split()
r = 0
b = 0
S = 0
for i in range(n):
	if int(a[i]) >= b:
		S = S + r * (int(a[i]) - b)
		r = r + 1
		b = int(a[i])
	else:
		S = S + b - int(a[i])
		r = r + 1
print(S)


n = int(input())
x = [int(i) for i in input().split()]
d = [max(x) - l for l in x]
print(sum(d))


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


n = int(input())
line = [int(i) for i in input().split()]
ref = max(line)
total = 0
for i in line:
	total += ref - i
print(str(total))


n = int(input())
l = [int(i) for i in input().split()]
c = 0
maxi = max(l)
for i in range(n):
	a = abs(l[i] - maxi)
	c += a
print(c)


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


n = int(input())
a = list(map(int, input().split()))
b = max(a)
c = min(a)
counter = count = 0
if b == c:
	print(0)
else:
	for i in range(len(a)):
		if a[i] == b:
			counter += 1
		if a[i] == 0:
			count += 1
	s = sum(a)
	ss = b * n
	print(ss - s)


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

def largest(arr, n):
	max = arr[0]
	for i in range(1, n):
		if arr[i] > max:
			max = arr[i]
	return max
larg = largest(arr, n)
sum = 0
for i in range(0, n):
	sum += abs(arr[i] - larg)
print(sum)


a1 = int(input())
a = input()
b = a.split(' ')
d = 0
e = 0
n = len(b)
for i in range(n):
	b[i] = int(b[i])
c = max(b)
for i in b:
	d = c - i
	e = e + d
print(e)


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


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


num = int(input())
ar = list(map(int, input().split()))
count = 0
for i in ar:
	count += max(ar) - i
print(count)


n = int(input())
well = [int(i) for i in input().split()]
high = max(well)
print(sum([high - i for i in well]))


a = int(input())
b = list((int(x) for x in input().split()))
maxi = max(b)
sumi = sum(b)
print(maxi * a - sumi)


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	alst = list(map(int, input().split()))
	max_ = max(alst)
	ans = 0
	for a in alst:
		ans += max_ - a
	print(ans)
main()


n = int(input())
estate = list(map(int, input().split()))
max_cit = max(estate)
spent = 0
for cit in estate:
	spent += max_cit - cit
print(spent)


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


n = int(input())
welfare = list(map(int, input().split()))
max_welfare = max(welfare)
spend = 0
for cw in welfare:
	spend += max_welfare - cw
print(spend)


n = int(input())
a = [int(x) for x in input().split()]
f = max(a)
sm = 0
for i in a:
	sm += f - i
print(sm)


n = int(input())
p = [int(i) for i in input().split()]
s = 0
m = max(p)
for i in range(len(p)):
	if p[i] < m:
		s = s + (m - p[i])
print(s)


people_num = int(input())
coins = list(map(int, input().split()))
if len(coins) > 1:
	largest = sorted(coins)[-1]
	result = 0
	for item in coins:
		result += largest - item
	print(result)
else:
	print(0)


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


n = int(input())
l = list(map(int, input().split()))
if len(l) == 1:
	print(0)
else:
	s = 0
	a = sorted(l)
	for i in range(len(l) - 1):
		s = s + (max(l) - a[i])
	print(s)


n = int(input())
nums = input()
nums = [int(i) for i in nums.split()]
print(max(nums) * len(nums) - sum(nums))


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


def ii():
	return int(input())

def fi():
	return float(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
n = ii()
a = li()
ans = max(a) * n - sum(a)
print(ans)


x = int(input())
z = input()
b = []
sum = 0
a = z.split(' ')
for g in range(x):
	b.append(int(a[g]))
c = sorted(b, reverse=True)
for f in range(x):
	sum = sum + (c[0] - c[f])
print(sum)


n = int(input())
s = input().split()
ma = -1
su = 0
for i in range(n):
	s[i] = int(s[i])
	if s[i] > ma:
		ma = s[i]
	su += s[i]
print(ma * n - su)


n = int(input())
l = [int(i) for i in input().split()]
b = 0
for i in l:
	b += max(l) - i
print(b)


n = int(input())
b = list(map(int, input().split()))
kolvo = 0
for i in range(n):
	if b[i] != b[b.index(max(b))]:
		kolvo += b[b.index(max(b))] - b[i]
print(kolvo)


n = int(input())
l = [int(x) for x in input().split()]
if n == 1:
	print(0)
else:
	p = [max(l) - int(x) for x in l]
	print(sum(p))


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


n = int(input())
l = list(map(int, input().split()))
l.sort()
sum = 0
m = l[n - 1]
for i in l:
	if m != i:
		sum = sum + abs(m - i)
print(sum)


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


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


n = int(input())
c = list(map(int, input().split()))
l = 0
m = max(c)
for i in range(n):
	l += m - c[i]
print(l)


n = int(input())
a = list(map(int, input().split()))
a.sort()
s = 0
for i in a:
	s = s + i
print(a[-1] * n - s)


n = int(input())
a = [int(i) for i in input().split()]
(p, count) = (max(a), 0)
a.sort()
for i in a:
	count += p - i
print(count)


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


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


n = input()
l = list(map(int, input().split()))
s = sum(l)
m = max(l)
if m * len(l) - s >= 0:
	print(m * len(l) - s)
else:
	print(0)


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


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


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


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


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


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


n = int(input())
l = list(map(int, input().split()))
mx = max(l)
print(sum(map(lambda x, mx=mx: mx - x, l)))


n = int(input())
A = list(map(int, input().split()))
(B, sum) = (max(A), 0)
A.sort()
for i in range(len(A) - 1):
	sum += B - A[i]
print(sum)


n = int(input())
ar = list(map(int, input().split()))
q = max(ar)
w = 0
for i in ar:
	w += q - i
print(w)


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


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


n = int(input())
a = list(map(int, input().split(' ')))
m = max(a)
c = sum([abs(x - m) for x in a])
print(c)


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


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


n = int(input())
total = 0
wages = [int(x) for x in input().split()]
for wage in wages:
	total += max(wages) - wage
print(total)


x = int(input())
a = [int(a) for a in input().strip().split(' ')]
z = max(a)
s = 0
for i in range(x):
	s += z - a[i]
print(s)


n = int(input())
numbers = input().split(' ')
total = 0
for i in range(n):
	numbers[i] = int(numbers[i])
maximum = max(numbers)
for number in numbers:
	total += maximum - number
print(total)


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


n = int(input())
l = list(map(int, input().split()))
maxi = max(l)
sum = 0
for i in l:
	sum += maxi - i
print(sum)


a = int(input())
b = [i for i in map(int, input().split())]
c = sorted(b)
d = c[a - 1]
e = 0
for t in c:
	u = d - t
	e += u
print(e)


n = int(input())
a = input().split()
if len(a) == n:
	u = 0
	maximum = 0
	for i in range(n):
		if int(a[i - 1]) > maximum:
			maximum = int(a[i - 1])
	for i in range(n):
		u = u + (maximum - int(a[i - 1]))
	print(u)
else:
	print(ERROR)


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


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


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


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


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


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


a = int(input())
s = input().split()
for i in range(a):
	s[i] = int(s[i])
(n, m) = (max(s), sum(s))
print(n * a - m)


a = int(input())
b = [int(x) for x in input().split()]
c = max(b)
total = 0
for x in b:
	total = total + (c - x)
print(total)


n = int(input())
arr = list(map(int, input().split()))
arr.sort(reverse=True)
burles = 0
if len(arr) == 1:
	print(0)
else:
	for values in arr:
		if arr[0] - values > 0:
			burles += arr[0] - values
	print(burles)


n = int(input())
citizens = input().split()
for i in range(n):
	citizens[i] = int(citizens[i])
welfare = max(citizens)
cost = 0
for i in range(n):
	cost += welfare - citizens[i]
print(cost)


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


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


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


def function1():
	remove = input()
	numbers = [int(x) for x in str(input()).split()]
	max_number = max(numbers)
	answer = 0
	for number in numbers:
		answer += abs(number - max_number)
	print(answer)
function1()


n = input()
bienestar = input().split(' ')
maximo = 0
for i in range(len(bienestar)):
	if int(bienestar[i]) > maximo:
		maximo = int(bienestar[i])
count = 0
for i in range(len(bienestar)):
	count += maximo - int(bienestar[i])
print(count)


n = int(input())
o = 0
z = 0
m = input().split()
for i in range(n):
	if int(m[i]) >= z:
		z = int(m[i])
for i in range(n):
	o += z - int(m[i])
print(o)


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


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


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


def welfare(n, a):
	max = 0
	sum = 0
	for i in range(0, n):
		if a[i] > max:
			max = a[i]
	for i in range(0, n):
		sum = sum + (max - a[i])
	print(sum)
n = int(input())
list1 = [int(i) for i in input().split()]
welfare(n, list1)


n = int(input())
ar = [int(i) for i in input().strip().split()]
ans = 0
m = max(ar)
for i in range(n):
	ans += m - ar[i]
print(ans)


a = int(input())
b = input().split()
s = 0
for i in range(a):
	b[i] = int(b[i])
	s += b[i]
print(max(b) * a - s)


n = int(input())
ll = list(map(int, input().split()))
m = -float('inf')
s = 0
for i in ll:
	s += i
	if i > m:
		m = i
print(n * m - s)


def solve(input_string):
	(num_of_citizens, wealths) = input_string.split('\n')
	citizen_wealths = wealths.split()
	wealths_int_ints = [int(w) for w in citizen_wealths]
	richest = max(wealths_int_ints)
	return sum([richest - wealth for wealth in wealths_int_ints])

def main():
	line1 = input()
	line2 = input()
	lines = '\n'.join([line1, line2])
	wealth_needed = solve(lines)
	print(wealth_needed)
	return wealth_needed
main()


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


import sys
n = int(sys.stdin.readline().split()[0])
wealthy = [int(i) for i in sys.stdin.readline().split()]
max_wealth = max(wealthy)
total = 0
for i in wealthy:
	total += max_wealth - i
print(total)


list = []
sum = 0
n = int(input())
m = input().split()
for i in range(n):
	list.append(int(m[i]))
max = max(list)
for i in range(len(list)):
	if list[i] < max:
		sum = sum + max - list[i]
print(sum)


n = int(input().strip())
a = [int(i) for i in input().strip().split()]
print(n * max(a) - sum(a))


n = int(input())
welfares = list(map(int, input().split()))
high = max(welfares)
req = 0
for i in welfares:
	req += abs(i - high)
print(req)


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


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


input()
a = list(map(int, input().split()))
z = max(a)
count = 0
for i in a:
	if i < z:
		count += z - i
print(count)


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


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


n = int(input())
l = sorted(map(int, input().split()))
ma = l[-1]
ans = 0
for x in l:
	ans += ma - x
print(ans)


n = int(input())
ls = [int(i) for i in input().split()]
ls.sort()
maxi = ls[len(ls) - 1]
res = 0
for i in ls:
	res += maxi - i
print(res)


n = int(input())
welfare = list(map(int, input().split()))
if n == 1:
	print(0)
if n != 1:
	rich = max(welfare)
	money = 0
	for i in range(n):
		money += abs(rich - welfare[i])
	print(money)


n = int(input())
alist = list(map(int, input().split()))
amin = min(alist)
amax = max(alist)
if amin == amax:
	print(0)
else:
	s = sum([amax - a for a in alist])
	print(s)


N = int(input())
L = list(map(int, input().split()))
maxi = max(L)
total = 0
for i in L:
	total += maxi - i
print(total)


n = int(input())
li = [int(x) for x in input().split()]
m = max(li)
x = [m - i for i in li]
print(sum(x))


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


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


t = int(input())
s = input().split(' ')
s = [int(i) for i in s]
count = 0
for i in s:
	count += max(s) - i
print(count)


a = input('')
a1 = int(a)
b = input('')
arr = [int(k) for k in b.split(' ')]
arr.sort()
sum = 0
for i in range(0, a1 - 1):
	sum = sum + (arr[a1 - 1] - arr[i])
print(sum)


n = int(input())
burles = list(map(int, input().split()))
most = max(burles)
total = 0
for i in range(n):
	total += most - burles[i]
print(total)


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


x = int(input())
y = input()
t = []
y = y.split()
for i in y:
	t.append(int(i))
cost = 0
for i in t:
	cost += max(t) - i
print(cost)


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


n = int(input())
lis = list(map(int, input().split()))
welfare = max(lis)
expense = 0
for a in lis:
	expense += welfare - a
print(expense)


n = int(input())
s = map(int, input().split())
sp = []
sp += s
m = max(sp)
res = 0
for i in sp:
	res += m - i
print(res)


n = int(input().strip())
arr = list(map(int, input().split()))
print((lambda s, arr: sum((s - i for i in arr)))(max(arr), arr))


n = int(input())
l = [int(i) for i in input().split()]
m = max(l)
count = 0
for i in l:
	if i < m:
		count += m - i
print(count)


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


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


def get_input():
	nb_citizens = int(input(''))
	tab_file = input('').split(' ')
	output(nb_citizens, tab_file)

def getmax(nb_citizens, tab_file):
	i = 0
	max = 0
	while i < nb_citizens:
		curr = int(tab_file[i])
		if curr > max:
			max = curr
		i += 1
	return max

def output(nb_citizens, tab_file):
	tab_max = getmax(nb_citizens, tab_file)
	i = 0
	ret = 0
	while i < nb_citizens:
		ret += tab_max - int(tab_file[i])
		i += 1
	print(ret)
get_input()


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


n = int(input())
r = list(map(int, input().split()))
max1 = max(r)
num = 0
for i in range(n):
	num += max1 - r[i]
print(num)


n = int(input())
arr = list(map(int, input().split()))
m = max(arr)
c = 0
for i in range(n):
	if arr[i] < m:
		c += m - arr[i]
print(c)


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


n = int(input())
s = input().split()
maks = int(s[0])
for i in range(1, len(s)):
	if int(s[i]) > maks:
		maks = int(s[i])
summ = 0
for i in range(len(s)):
	summ += maks - int(s[i])
print(summ)


n = int(input())
ai = [int(i) for i in input().split()]
ai = sorted(ai)
SUM = 0
for i in range(n - 1):
	SUM += max(ai) - ai[i]
print(SUM)


n = int(input())
a = [int(j) for j in input().split()]
maxi = 0
for i in range(n):
	if a[i] > maxi:
		maxi = a[i]
sum = 0
for i in range(n):
	sum += maxi - a[i]
print(sum)


n = int(input())
a = list(map(int, input().split()))
a.sort()
k = a[-1]
cnt = 0
for i in a:
	cnt += k - i
print(cnt)


count = input()
s = [int(i) for i in input().split()]
maxS = max(s)
result = 0
for i in s:
	result += maxS - i
print(result)


n = int(input())
count = 0
k = []
a = list(map(int, input().split()))
if len(a) == 1:
	print(0)
else:
	for i in range(len(list(a))):
		if a[i] < max(a):
			count = max(a) - a[i]
			k.append(count)
	print(sum(k))


input()
citizens = list(map(int, input().split()))
max_welfare = max(citizens)
difference = sum(map(lambda x: max_welfare - x, citizens))
print(difference)


n = int(input())
l = list(map(int, input().split()))
l.sort()
k = 0
for i in range(0, n):
	k = k + l[-1] - l[i]
print(k)


n = int(input())
ch = input()
l = list(map(int, ch.split(' ')))
m = max(l)
k = 0
for i in range(n):
	k = k + l[i]
j = m * n - k
print(j)


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


_ = input()
arr = list(map(int, input().split()))
total = 0
maximum = max(arr)
for k in range(len(arr)):
	if arr[k] < maximum:
		total += maximum - arr[k]
print(total)


n = int(input())
welfare = list(map(int, input().split()))
sum = 0
welfare.sort()
if n == 1:
	print(0)
else:
	for j in range(n - 1):
		sum += welfare[n - 1] - welfare[j]
	print(sum)


n = int(input())
args = input().split(' ')
for i in range(0, len(args)):
	args[i] = int(args[i])
summe = 0
for arg in args:
	summe += max(args) - arg
print(summe)


n = int(input())
citizens = [int(x) for x in input().split(' ')]
target = max(citizens)
print(sum((target - citizen for citizen in citizens)))


n = int(input())
arr = list(map(int, input().split()))
sum = 0
arr_m = max(arr)
for i in range(len(arr)):
	sum = sum + (arr_m - arr[i])
print(sum)


try:
	n = int(input())
	l = list(map(int, input().split()))
	s = max(l)
	a = s * n
	t = sum(l)
	b = a - t
	print(b)
except:
	pass


citizens = int(input())
welfare = list(map(int, input().split()))
maxx = max(welfare)
print(sum([maxx - x for x in welfare]))


n = int(input())
l = list(map(int, input().split()))
sum = 0
if len(l) == 1:
	print(0)
else:
	for i in range(len(l)):
		sum += max(l) - l[i]
	print(sum)


a = int(input())
b = list(map(int, input().split()))
c = 0
if a == len(b):
	for i in b:
		if i < max(b):
			rizn = max(b) - i
			c = c + rizn
else:
	print('Неправильно вказано а')
print(c)


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


a = int(input())
b = input()
c = [int(x) for x in b.split()]
max = 0
for i in range(0, a):
	if c[i] > max:
		max = c[i]
tambahan = 0
for i in range(0, a):
	tambahan = tambahan + (max - c[i])
print(tambahan)


import sys
n = int(input())
peoples = list(map(int, input().split()))
max_value = max(peoples)
add_money = -sum(list(map(lambda x: x - max_value, peoples)))
print(add_money)


a = int(input())
s = input().split(' ')
max = -1
for i in s:
	if int(i) > max:
		max = int(i)
ans = 0
for i in s:
	if int(i) < max:
		ans += max - int(i)
print(ans)


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


n = int(input())
i = list(map(int, input().split()))
highest = 0
count = 0
for a in range(0, n):
	if i[a] > highest:
		highest = i[a]
for a in range(0, n):
	if i[a] < highest:
		count = count + highest - i[a]
print(count)


def get_comp(arr, ans, max):
	if len(arr) == 0:
		return ans
	else:
		return get_comp(arr[1:], ans + (max - arr[0]), max)
d = input()
arr = [int(x) for x in input().split()]
max = max(arr)
print(get_comp(arr, 0, max))


n = int(input())
line = str(input()).split()
line = [int(it) for it in line]
print(n * max(line) - sum(line))


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


n = int(input())
a = [0] * n
a = [int(x) for x in input().split()]
a.sort()
m = a[n - 1]
sum = 0
for i in range(n):
	sum = sum + m - a[i]
print(sum)


n = int(input())
l = [int(x) for x in input().split(' ')]
k = max(l)
res = sum([k - x for x in l])
print(res)


input()
wealth = list(map(int, input().split(' ')))
desired = max(wealth)
needed = 0
for i in wealth:
	needed += int(desired) - int(i)
print(needed)


n = int(input())
m = list(map(int, input().split()))
n = len(m)
a = []
for i in range(n):
	s = max(m) - m[i]
	a.append(s)
print(sum(a))


n = int(input())
l = list(map(int, input().split()))
m = max(l)
count = 0
s = 0
c = 0
for i in range(n):
	if l[i] != m:
		s = m - l[i]
		c = c + s
print(c)


n = input()
a = list(map(int, input().split()))
m = max(a)
s = 0
for aa in a:
	if aa < m:
		s += m - aa
print(s)


import sys
from bisect import bisect_left, bisect_right
from collections import deque, Counter
from math import gcd, sqrt, factorial, ceil, log10
from itertools import permutations
inf = float('inf')
mod = 1000000007
mini = 1000000007

def ncr(n, r):
	d = 10 ** 9 + 7
	num = fact(n)
	den = fact(r) * fact(n - r) % d
	den = pow(den, d - 2, d)
	return num * den % d

def sieve(n):
	prime = [True for i in range(n + 1)]
	lst = []
	p = 2
	while p * p <= n:
		if prime[p]:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p = p + 1
	for i in range(2, n + 1):
		if prime[i]:
			lst.append(i)
	return lst

def binary(number):
	result = 0
	while number:
		result = result + 1
		number = number & number - 1
	return result

def calculate_factors(n):
	hh = [1] * (n + 1)
	p = 2
	while p * p < n:
		if hh[p] == 1:
			for i in range(p * 2, n, p):
				hh[i] = 0
		p += 1
	total = 1
	for p in range(2, n + 1):
		if hh[p] == 1:
			count = 0
			if n % p == 0:
				while n % p == 0:
					n = int(n / p)
					count += 1
				total *= count + 1
	return total

def prime_factors(n):
	i = 2
	factors = set()
	while i * i <= n:
		if n % i:
			i += 1
		else:
			factors.add(n // i)
			n = n // i
			factors.add(i)
	if n > 1:
		factors.add(n)
	return factors

def isPrime(n):
	if n == 2 or n == 3:
		return True
	if n % 2 == 0 or n < 2:
		return False
	for i in range(3, int(n ** 0.5) + 1, 2):
		if n % i == 0:
			return False
	return True

def solve(n):
	if n == 1:
		return 1
	p = 2
	while p * p <= n:
		if n % p == 0:
			return n // p
		p = p + 1
	return False

def expo(x, n):
	result = 1
	while n > 1:
		if n & 1:
			n = n - 1
			result = result * x
		else:
			n = n // 2
			x = x * x
	return result * x

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
n = int(input())
Arr = get_array()
if n == 1:
	print(0)
else:
	maxi = max(Arr)
	count = 0
	for i in Arr:
		count = count + (maxi - i)
	print(count)


n = int(input())
a = [int(i) for i in input().split()]
ma = max(a)
ans = 0
for i in a:
	ans = ans + max(a) - i
print(ans)


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


num_citizens = int(input())
list_welfare = [int(x) for x in input().split()]
welfare_sort = sorted(list_welfare, reverse=True)
spend = 0
for i in range(1, num_citizens):
	spend = spend + abs(welfare_sort[0] - welfare_sort[i])
print(spend)


(n, answer) = (int(input()), 0)
data = sorted([int(x) for x in input().split()])
for i in data:
	answer += data[n - 1] - i
print(answer)


n = int(input())
arr = list(map(int, input().split()))
count = 0
max1 = max(arr)
for i in range(n):
	count = count + (max1 - arr[i])
print(count)


x = int(input())
numbers = [int(i) for i in input().split()]
largest_number = -1
payout = 0
for i in range(len(numbers)):
	if numbers[i] > largest_number:
		largest_number = numbers[i]
for i in range(len(numbers)):
	payout += largest_number - numbers[i]
print(payout)


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


n = int(input())
l = [int(x) for x in input().split()]
m = max(l)
sum = 0
if n > 1:
	for i in l:
		if i < m:
			sum += m - i
	print(sum)
else:
	print(0)


n = int(input())
array = list(map(int, input().split()))
array.sort()
sum1 = int(0)
for x in range(n):
	sum1 += array[n - 1] - array[x]
print(sum1)


n = int(input())
numbers = [int(num) for num in input().split(' ', n - 1)]
Max = max(numbers)
count = 0
for i in numbers:
	if i < Max:
		i = Max - i
		count += i
print(count)


inp1 = int(input())
inp2 = input().split()
inp2 = list(map(int, inp2))
m = max(inp2)
c = 0
p = 0
for i in range(inp1):
	p = m - inp2[i]
	c = c + p
print(c)


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


n = int(input())
lst = list(map(int, input().split()))
count = 0
for ele in lst:
	count = count + max(lst) - ele if ele < max(lst) else count
print(count)


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


import sys
import os
import math
import operator
mod = 1000000007
Mod = 998244353

def Pow(x, y):
	if y == 0:
		return 1
	p = Pow(x, y // 2) % mod
	p = p * p % mod
	if y % 2 == 0:
		return p
	else:
		return x * p % mod

def modInv(a, m):
	return Pow(a, m - 2)

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)
n = int(input())
a = [int(x) for x in input().split()]
a.sort()
res = 0
for i in range(n):
	res += a[n - 1] - a[i]
print(res)


n = input()
arr = list(map(int, input().split()))
mx = max(arr)
print(sum((mx - a for a in arr)))


n = input()
x = input().split()
b = []
for i in x:
	b.append(int(i))
m = max(b)
s = 0
for j in b:
	if j != m:
		s = s + m - j
print(s)


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


a = [0 for x in range(1, 1010)]
ma = 0
n = int(input())
b = input()
a = [int(n) for n in b.split()]
for i in range(0, n):
	ma = max(ma, a[i])
sum = 0
for i in range(0, n):
	sum += ma - a[i]
print(sum)


n = int(input())
l = [int(x) for x in input().split()]
m = max(l)
total = 0
for i in range(len(l)):
	total += m - l[i]
print(total)


citizens = input('')
money = input('').split()
money = list(map(int, money))
richest = max(money)
ans = 0
for i in money:
	ans += richest - i
print(ans)


from sys import stdin
inFile = stdin
tokens = []
tokens_next = 0

def next_str():
	global tokens, tokens_next
	while tokens_next >= len(tokens):
		tokens = inFile.readline().split()
		tokens_next = 0
	tokens_next += 1
	return tokens[tokens_next - 1]

def nextInt():
	return int(next_str())
n = nextInt()
a = [nextInt() for i in range(n)]
a.sort(reverse=True)
s = 0
for i in a[1:]:
	s += a[0] - i
print(s)


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


n = int(input())
lis = sorted(map(int, input().split()))
a = lis[-1]
ans = 0
for i in lis:
	ans += a - i
print(ans)


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


def main():
	n = input()
	assets = [int(x) for x in input().split()]
	richest = max(assets)
	welfare = 0
	for a in assets:
		welfare += richest - a
	print(welfare)
main()


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


n = int(input())
a = [int(x) for x in input().split()]
bigger = max(a)
money = 0
for c in a:
	money += bigger - c
print(money)


n = int(input())
a = [int(i) for i in input().split()]
maxi = max(a)
changes = [maxi - i for i in a]
print(sum(changes))


input()
a = list(map(int, input().split()))
count = 0
for element in a:
	if element == max(a):
		count += 0
	elif element < max(a):
		count += max(a) - element
print(count)


n = int(input())
A = list(map(int, input().split(' ')))
hi = max(A)
tot = 0
for el in A:
	tot += hi - el
print(tot)


num_ppl = int(input())
inp = input()
inp = inp.split(' ')
lst_ppl = []
for current_num in inp:
	lst_ppl.append(int(current_num))
print(max(lst_ppl) * num_ppl - sum(lst_ppl))


n = int(input())
array = list(map(int, input().split()[:n]))
array.sort()
ans = 0
for x in range(n):
	c = array[-1] - array[x]
	ans += c
print(ans)


inp = int(input())
inp1 = input().split()
total = 0
for x in range(len(inp1)):
	inp1[x] = int(inp1[x])
inp1 = sorted(inp1)
for c in range(len(inp1) - 1):
	total += abs(inp1[-1] - inp1[c])
print(total)


input()
y = 0
(*l,) = map(int, input().split())
x = max(l)
for i in l:
	y += x - i
print(y)


n = int(input())
people = tuple(sorted(map(int, input().split())))
s = 0
for i in range(n - 1):
	s = s + max(people) - people[i]
else:
	print(s)


n = int(input())
arr = []
p = 0
arr = list(map(int, input().split()))
for i in range(len(arr)):
	if arr[i] < max(arr):
		p += max(arr) - arr[i]
print(p)


n = int(input())
x = [int(x) for x in input().split()]
m = max(x)
b = 0
for num in x:
	if num != m:
		b += m - num
print(b)


k = int(input())
l = list(map(int, input().split()))
h = max(l)
c = 0
for i in l:
	c = c + (h - i)
print(c)


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


n = int(input())
Mon = list(map(int, input().split()))
rez = 0
sred = max(Mon)
for elem in Mon:
	rez += sred - elem
print(rez)


n = int(input())
s = 0
l = [int(x) for x in input().split()]
u = max(l)
for i in range(0, len(l)):
	s = s + (u - l[i])
print(s)


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


n = int(input())
citizens = list(map(int, input().strip().split()))
citizens.sort()
target = citizens[n - 1]
S = 0
for i in range(n - 1):
	S += target - citizens[i]
print(S)


n = int(input())
x = [0 for i in range(n)]
s = input().split(' ')
for i in range(len(s)):
	x[i] = int(s[i])
maxn = max(x)
answer = 0
for i in x:
	answer += maxn - i
print(answer)


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


x = int(input())
y = list(map(int, input().split()))
count = 0
y.sort()
m = y[x - 1]
for i in range(x):
	p = m - y[i]
	count = count + p
print(count)


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


length = int(input())
arr = input().split(' ')
arr = [int(i) for i in arr]
target = max(arr)
minimum_burles = 0
for i in arr:
	if i != target:
		minimum_burles += target - i
print(minimum_burles)


citizens = int(input())
welfare = list(map(int, input().split()))
spending = 0
maximum = max(welfare)
length = len(welfare)
for i in range(length):
	if welfare[i] < maximum:
		spending += maximum - welfare[i]
print(spending)


n = int(input())
S = 0
a = list(map(int, input().split()))
for j in a:
	S += j
print(max(a) * n - S)


n = int(input())
a = input()
a = a.split()
i = 0
while i < n:
	new = int(a[i])
	a[i] = new
	i = i + 1
amax = max(a)
i = 0
s = 0
while i < n:
	s = s + amax - a[i]
	i = i + 1
print(s)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return input()

def main():
	n = I()
	l = LI()
	mx = max(l)
	sm = 0
	for x in l:
		sm += mx - x
	return sm
print(main())


t = int(input())
c = 0
n = list(map(int, input().split()))
n.sort()
z = n[-1]
for i in range(len(n) - 1):
	if n[i] != z:
		c = c + (z - n[i])
print(c)


a = input()
a = list(map(int, input().split()))
m = max(a)
total = 0
for el in a:
	total += m - el
print(total)


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


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


n = int(input())
welfare = input().split(' ')
welfare = list(map(int, welfare))
max_value = max(welfare)
min_burles = 0
for i in range(n):
	temp = max_value - welfare[i]
	min_burles += temp
print(min_burles)


n = int(input())
a = list(map(int, input().split()))
otv = []
for i in range(len(a)):
	k = max(a)
	otv.append(k - a[i])
print(sum(otv))


n = int(input())
a = [int(i) for i in input().split()]
t = 0
for i in range(len(a)):
	t += a[i]
print(max(a) * n - t)


size = int(input())
ls = list(map(int, input().split()))
ls.sort()
max = ls[-1]
sum = 0
for i in range(size):
	sum += max - ls[i]
print(sum)


n = int(input())
p = list((int(a) for a in input().split()))
print(max(p) * n - sum(p))


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


size = int(input())
welfare = list(map(int, input().split()))
max_welfare = max(welfare)
total = 0
for i in welfare:
	total = total + (max_welfare - i)
print(total)


n = int(input())
arr = list(map(int, input().split()))
(welfare, r) = (max(arr), 0)
for i in range(n):
	r += abs(arr[i] - welfare)
print(r)


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


n = int(input())
a = [int(i) for i in input().split()]
max_a = max(a)
print(n * max_a - sum(a))


x = int(input())
v = 0
z = []
c = 0
i = 0
b = 0
n = 0
a = input('')
z = list(map(int, a.split()))
M = max(z)
while True:
	if z[i] < M:
		c = int(M) - int(z[i])
		n = n + c
	i = i + 1
	b = b + 1
	if b == len(z):
		break
print(n)


i = input()
t = input()
A = []
for x in t.split():
	A.append(int(x))
m = max(A)
r = 0
for j in A:
	r = r + m - j
print(r)


n = int(input())
wellfare = [int(a) for a in input().split()]
max_wellfare = max(wellfare)
cost = 0
for el in wellfare:
	cost += max_wellfare - el
print(cost)


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


n = int(input())
max = 0
total = 0
inputs = input().split(' ')
for i in range(len(inputs)):
	inputs[i] = int(inputs[i])
for i in range(n):
	if inputs[i] > max:
		max = inputs[i]
for i in range(n):
	total += max - inputs[i]
print(total)


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


n = int(input())
a = list(map(int, input().split()))
one = False
f = 0
if n == 1:
	one = True
else:
	a.sort()
	for i in range(n):
		f += a[-1] - a[i]
if one:
	print(0)
else:
	print(f)


print(*[sum(map(lambda x: max(a) - x, a)) for a in [input(), list(map(int, input().split()))][1:]])


n = int(input())
lista = [int(i) for i in input().split()]
naj = max(lista)
zbroj = 0
for i in lista:
	zbroj += naj - i
print(zbroj)


t = int(input())
l = list(map(int, input().split()))
val = max(l)
ans = 0
for i in range(t):
	ans += val - l[i]
print(ans)


n = int(input())
ai = input().split()
max = int(ai[0])
res = list(map(int, ai))
cal = 0
s = 0
for i in range(n):
	if max < res[i]:
		max = res[i]
for j in range(n):
	cal = max - res[j]
	s = s + cal
print(s)


n = int(input())
a = input().split()
x = 0
while x < len(a):
	a[x] = int(a[x])
	x = x + 1
a.sort()
x = 0
z = 0
while x < len(a):
	z = z + a[-1] - a[x]
	x = x + 1
print(z)


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


n = int(input())
x = [int(i) for i in input().split()]
x.sort()
count = 0
maxi = x[len(x) - 1]
for i in range(len(x) - 1):
	if x[i] < maxi:
		diff = maxi - x[i]
		count = count + diff
print(count)


w = int(input())
p = list(map(int, input().split()))
print(max(p) * w - sum(p))


n = int(input())
q = input().split()
l = [int(i) for i in q]
l.sort(reverse=True)
top = l[0]
c = 0
for i in range(n):
	if i == 0:
		pass
	else:
		c += top - l[i]
print(c)


n_len = int(input())
a = [int(x) for x in input().split()]
sum_all = 0
max_a = max(a)
for i in a:
	if i < max_a:
		sum_all += max_a - i
print(sum_all)


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


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nlargest, nsmallest, _heapify_max, _heapreplace_max
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as c
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from fractions import Fraction
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
n = int(data())
arr = l()
m = max(arr)
answer = 0
for i in arr:
	answer += m - i
out(answer)


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


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


t = int(input())
arr = [int(x) for x in input().split()]
m = 0
for i in arr:
	if i > m:
		m = i
r = 0
for i in arr:
	r += m - i
print(r)


def main():
	n = int(input())
	s = list(map(int, input().split()))
	m = max(s)
	print(m * len(s) - sum(s))
main()


a = int(input())
b = sorted(map(int, input().split()))
k = int(0)
i = int(0)
while i != a - 1:
	k = k + b[a - 1] - b[i]
	i = i + 1
print(k)


a = int(input())
q = 0
s = list(map(int, input().split()))
for i in s:
	if i < max(s):
		q += max(s) - i
print(q)


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


n = int(input())
line = list(map(lambda i: int(i), input().split()))
max = max(line)
sum = 0
for i in range(0, n):
	sum += max - line[i]
print(sum)


n = int(input())
mas = [int(x) for x in input().split()]
z = max(mas)
mas1 = []
for i in mas:
	mas1.append(z - i)
print(sum(mas1))


n = int(input())
m = [int(i) for i in input().split()]
ma = max(m)
c = 0
for i in range(n):
	c += ma - m[i]
print(c)


n = int(input(''))
l = list(map(int, input().split()))
e = max(l)
sp = e * len(l) - sum(l)
print(sp)


n = int(input())
king = list(map(int, input().split()))
king.sort()
count = 0
for i in king:
	count += king[-1] - i
print(count)


t = int(input())
l = list(map(int, input().split()))
l.sort()
max = l[-1]
c = 0
for i in l:
	c = c + (max - i)
print(c)


n = int(input())
nums = [int(x) for x in input().split()]
high = max(nums)
if n <= 1:
	print(0)
else:
	equalizers = []
	for i in range(0, n):
		if nums[i] == high:
			continue
		else:
			equalizers.append(high - nums[i])
	print(sum(equalizers))


def celebration(lst):
	dohod = 0
	mx = max(lst)
	for i in range(len(lst)):
		dohod += mx - lst[i]
	return dohod
n = int(input())
print(celebration([int(i) for i in input().split()]))


a = int(input())
ls = [int(items) for items in input().split(' ')]
b = max(ls)
sum = 0
for x in ls:
	sum += b - x
print(sum)


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


n = int(input())
line = [int(x) for x in input().split()]
summ = 0
if len(line) == 1:
	print(0)
else:
	for i in range(len(line)):
		summ += max(line) - line[i]
	print(summ)


total = int(input())
wealth = [int(a) for a in input().split()]
Max = max(wealth)
welfare = 0
for numb in wealth:
	welfare += Max - numb
print(welfare)


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
mx = arr[n - 1]
ans = 0
if arr[0] >= mx:
	ans = 0
else:
	for i in range(n):
		ans += mx - arr[i]
print(ans)


n = int(input())
s = input().split()
t = 0
s1 = []
for i in range(n):
	s1.append(int(s[i]))
	t = t + s1[i]
k = max(s1)
print(k * n - t)


n = input()
L = [int(s) for s in input().split()]
m = max(L)
res = sum([m - x for x in L])
print(res)


n = int(input())
list1 = list(map(int, input().strip().split(' ')))
sum1 = 0
for i in list1:
	sum1 += i
sum2 = max(list1) * len(list1)
print(sum2 - sum1)


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


t = int(input())
a = list(map(int, input().split()))
max = max(a)
sum = 0
for i in a:
	b = max - i
	sum = sum + b
print(sum)


input()
input_list = input().split()
for i in range(len(input_list)):
	input_list[i] = int(input_list[i])
max_num = max(input_list)
count_burles = 0
for num in input_list:
	count_burles += max_num - num
print(count_burles)


n = int(input())
w = [int(i) for i in input().split()]
total = 0
m = max(w)
for i in range(n):
	if w[i] != m:
		total += m - w[i]
print(total)


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


import sys
import math
c = int(input())
l = [int(j) for j in input().split()]
print(c * max(l) - sum(l))


num_citizens = int(input())
welfare = list(map(int, input().split()))
mayor = 0
for i in range(0, num_citizens):
	if i == 0:
		mayor = welfare[0]
	elif welfare[i] > mayor:
		mayor = welfare[i]
count_money = 0
for i in range(0, num_citizens):
	if welfare[i] < mayor:
		count_money = mayor - welfare[i] + count_money
print(count_money)


from sys import stdin
maxx = 0
pas = 0
n = int(input())
a = [int(x) for x in stdin.readline().split()]
maxx = max(a)
for i in range(n):
	if maxx > a[i]:
		pas = pas + (maxx - a[i])
print(pas)


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


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


n = int(input())
ar = [int(i) for i in input().split()]
c = 0
for i in ar:
	c += max(ar) - i
print(c)


n = int(input())
a = sorted(list(map(int, input().split())))
print(a[-1] * len(a) - sum(a))


def main():
	input()
	lst = list(map(int, input().split()))
	lst.sort()
	total = 0
	for x in lst:
		total += lst[-1] - x
	print(total)
main()


n = int(input())
Sum = 0
Max = 0
for x in map(int, input().split()):
	Sum = Sum + x
	Max = max(x, Max)
print(Max * n - Sum)


a = int(input())
b = list(map(int, input().split(' ')))
c = max(b)
sum = 0
for k in b:
	sum += c - k
print(sum)


n = int(input())
s = list(map(int, input().split(' ')))
s.sort()
sum1 = 0
if len(s) != 1:
	for i in s:
		sum1 += s[-1] - i
	print(sum1)
else:
	print(0)


n = int(input())
lst = input().split()
lst2 = [int(i) for i in lst]
y = max(lst2)
count = 0
for a in lst2:
	count += a
x = n * y - count
print(x)


n = int(input())
welfare = list(map(int, input().split()))
print(sum([max(welfare) - welfare_each for welfare_each in welfare]), end='')


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


def macinco():
	n = int(input())
	if n == 1:
		return 0
	nums = [int(i) for i in input().split()]
	nums.sort(reverse=True)
	max = nums[0]
	res = 0
	for i in range(1, n):
		res += max - nums[i]
	return res
print(str(macinco()))


a = int(input())
d = input().split()
for i in range(len(d)):
	d[i] = int(d[i])
maxd = d[0]
ans = 0
d.sort()
for i in d:
	ans += d[-1] - i
print(ans)


n = int(input())
L = input()
L = L.split()
suma = 0
for k in range(n):
	L[k] = int(L[k])
L.sort(reverse=True)
for p in range(1, n):
	j = L[0] - L[p]
	suma += j
print(suma)


t = int(input())
nums = list(map(int, input().split()))
maxw = nums[0]
tot = 0
for x in nums:
	if x > maxw:
		maxw = x
	tot += x
diff = maxw * t - tot
print(diff)


n = int(input().strip())
ll = list(map(int, input().split()))
ll1 = [0] * n
k = max(ll)
for i in range(n):
	ll1[i] = k - ll[i]
print(sum(ll1))


n = int(input())
sp = list(map(int, input().split()))
maxs = max(sp)
ans = 0
for el in sp:
	ans += maxs - el
print(ans)


input()
li = list(map(int, input().split()))
ans = 0
ans += sum((max(li) - x for x in li))
print(ans)


i = int(input())
j = list(map(int, input().split()))
maxx = max(j)
need = 0
for a in j:
	if a != maxx:
		money = maxx - a
		need = need + money
print(need)


n = int(input())
mas = [int(i) for i in input().split()]
m = max(mas)
print(sum(map(lambda x: m - x, mas)))


x = int(input())
y = list(map(int, input().split()))
print(max(y) * x - sum(y))


n = input().split()
k = input().split()
c = 0
l = []
for j in k:
	l.append(int(j))
m = max(l)
for i in k:
	c += m - int(i)
print(c)


a = int(input())
l = list(map(int, input().split()))
k = 0
d = max(l)
for i in l:
	if i < d:
		k = k + d - i
print(k)


n = int(input())
l = []
x = input().split()
c = int(0)
c1 = int(0)
for i in range(n):
	a = x[i]
	c = int(c) + int(a)
	if int(a) > int(c1):
		c1 = a
print(int(n) * int(c1) - c)


n = int(input())
array = list(map(int, input().split()))
may = 0
for i in array:
	may = max(may, i)
con = 0
for i in array:
	con += may - i
print(con)


x = int(input())
y = map(int, input().split())
lst = []
maxi = 0
total = 0
for z in y:
	lst.append(z)
for a in range(0, x):
	if lst[a] > maxi:
		maxi = lst[a]
for b in range(0, x):
	total += maxi - lst[b]
print(total)


n = int(input())
s = input().split()
l = []
c = 0
for a in range(len(s)):
	l.append(int(s[a]))
l.sort()
limite = len(l) - 1
for a in range(limite):
	c += abs(l[limite] - l[a])
print(c)


input()
k = 0
(*a,) = map(int, input().split())
for i in a:
	k = k + max(a) - i
print(k)


input()
a = list(map(int, input().split()))
ma = max(a)
if len(a) == 1:
	print(0)
else:
	print(sum([ma - i for i in a]))


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


N = int(input())
A = list(map(int, input().split()))
maxv = max(A)
B = [maxv - a for a in A]
ans = sum(B)
print(ans)


x = input()
y = input().split()
p = []
s = []
for i in y:
	p.append(int(i))
m = max(p)
count = 0
for i in p:
	count = count + (m - i)
print(count)


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


n = int(input())
l = list(map(int, input().split()))
m = max(l)
count = 0
for i in range(len(l)):
	count = count + (m - l[i])
print(count)


n = int(input())
numbers = list(map(int, input().split()))
max_v = max(numbers)
gift = 0
for i in range(n):
	gift += max_v - numbers[i]
print(gift)


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


x = int(input())
a = list(map(int, input().split()))
y = max(a)
counter = 0
for i in a:
	if i != y:
		counter += y - i
print(counter)


n = int(input())
data = [int(x) for x in input().split()]
max = max(data)
sum = 0
for x in data:
	sum += max - x
print(sum)


n = int(input())
l = list(map(int, input().split()))
a = 0
maxi = l[0]
for i in range(len(l)):
	if l[i] > maxi:
		maxi = l[i]
	else:
		maxi = maxi
for i in range(len(l)):
	a = a + (maxi - l[i])
print(a)


b = 0
n = int(input())
l = list(map(int, input().split()))
for i in range(n):
	if l[i] != max(l):
		b += max(l) - l[i]
		continue
	elif len(l) == 1:
		print('0')
		break
else:
	print(b)


n = int(input())
l = list(map(int, input().split(' ')))
sum = 0
m = max(l)
if n > 1:
	for i in l:
		sum += m - i
print(sum)


n = int(input())
s = sorted(map(int, input().split()))
count = 0
a = s[-1]
s.pop()
for i in s:
	count += a - i
print(count)


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


n = int(input())
citizens = [int(x) for x in input().split()]
maximum = max(citizens)
count = 0
for citizen in citizens:
	count += maximum - citizen
print(count)


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


x = input()
y = list(map(int, input().split()))
print(sum((abs(i - max(y)) for i in y)))


n = int(input())
z = str(input())
d = z.split()
s = []
for i in d:
	i = int(i)
	s += [i]
s.sort(reverse=True)
l = s[0]
s.pop(0)
ans = 0
for i in s:
	ans += l - i
print(ans)


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


from functools import reduce
input()
a = list(map(int, input().split()))
print(max(a) * len(a) - reduce(lambda x, y: x + y, a))


n = int(input())
people = list(map(int, input().split()))
idial = max(people)
k = 0
for i in people:
	k += idial - i
print(k)


input()
items = [int(x) for x in input().split()]
m = max(items)
print(sum((m - x for x in items)))


num = int(input())
arr = input()
arr = arr.split(' ')
maximum = max([int(i) for i in arr])
Expense = 0
for i in arr:
	Expense += maximum - int(i)
print(Expense)


import sys
import math
import bisect

def main():
	n = int(input())
	A = list(map(int, input().split()))
	ans = 0
	max_val = max(A)
	for a in A:
		ans += max_val - a
	print(ans)
main()


n = int(input())
citizen = input().split()
hasil = 0
b = 0
for i in citizen:
	if int(i) > b:
		b = int(i)
for j in citizen:
	if int(j) < b:
		hasil += b - int(j)
print(hasil)


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


n = int(input())
a = list(map(int, input().split()[:n]))
m = max(a)
if a.count(m) > 1:
	k = [i for (i, j) in enumerate(a) if j == m]
	s = 0
	l = len(k)
	for i in k:
		s += a[i]
	print((n - l) * m - (sum(a) - s))
else:
	print((n - 1) * m - (sum(a) - m))


n = int(input())
mx = 0
sum = 0
lst = input().split()
for i in range(n):
	lst[i] = int(lst[i])
	if lst[i] > mx:
		mx = lst[i]
for i in range(n):
	sum += mx - lst[i]
print(sum)


n = int(input())
ls = sorted(list(map(int, input().split())))
kq = 0
for i in range(n - 1):
	kq += ls[n - 1] - ls[i]
print(kq)


n = int(input())
l = list(input().split())
a = []
for i in range(n):
	a.append(int(l[i]))
summation = 0
m = max(a)
a.remove(m)
for i in range(n - 1):
	summation += m - a[i]
print(summation)


n = int(input())
a = list(map(int, input().split()))
a.sort()
print(a[-1] * n - sum(a))


citizens = int(input())
citizen_balance = list(map(int, input().split()))
max_money_value = max(citizen_balance)
print(sum((max_money_value - citizen_balance[i] for i in range(citizens) if max_money_value != citizen_balance[i])))


def equality(values):
	count = 0
	maximum = max(values)
	for i in range(len(values)):
		count = count + (maximum - values[i])
	return count
n = int(input())
values = list(map(int, input().split()))
print(equality(values))


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


n = int(input())
li = [int(num) for num in input().split(' ', n - 1)]
li.sort()
tk = 0
for i in range(len(li)):
	tk += max(li) - li[i]
print(tk)


n = int(input())
L = []

def maxi(L):
	sum = 0
	ele = max(L)
	for i in L:
		sum = sum + (ele - i)
	return sum
x = [i for i in input().split(' ')]
for i in x:
	i = int(i)
	L.append(i)
if len(L) == 1:
	print('0')
else:
	print(maxi(L))


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


l = int(input())
d = list(map(int, input().split()))[:l]
o = max(d)
c = 0
for i in range(len(d)):
	c = c + (o - d[i])
print(c)


NUM_CASES = input()
INTS = [int(n) for n in input().split()]
MAX = max(INTS) if INTS else 0

def diff(x):
	return MAX - x
INTS = [diff(x) for x in INTS]
TOTAL = sum(INTS)
print(TOTAL)


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())
arr = list(map(int, input().split(' ')))
s = 0
for i in arr:
	s += max(arr) - i
print(s)


no = input()
a = input().split()
for r in range(len(a)):
	a[r] = int(a[r])
ans = 0
for each in a:
	ans += max(a) - each
print(ans)


n = int(input())
array = list(map(int, input().split()))
summ = sum(array)
mx = max(array)
count = 0
for i in array:
	if i != mx:
		count += mx - i
print(count)


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


b = int(input())
a = list(map(int, input().split()))
o = max(a)
res = 0
for i in a:
	res += o - i
print(res)


n = int(input())
nums = list(map(int, input().split()))
h = max(nums)
cnt = 0
for i in nums:
	while i < h:
		i = int(i + 1)
		cnt += 1
print(cnt)


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
ans = 0
for i in range(n):
	welfare = arr[n - 1] - arr[i]
	ans = welfare + ans
print(ans)


input()
s = list(map(int, input().split()))
print(sum([max(s) - e for e in s]))


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


input()
k = list(map(int, input().split()))
ret = 0
for i in k:
	ret += max(k) - i
print(ret)


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


num = int(input())
l = input().split(' ')
li = [int(i) for i in l]
m = max(li)
s = 0
for i in range(num):
	if int(l[i]) != m:
		s += int(m) - int(l[i])
print(s)


n = int(input())
l = list(map(int, input().split()))
m = max(l)
k = l.count(m)
print((n - k) * m - sum(l) + k * m)


a = int(input())
b = list(map(int, input().split()))
c = max(b)
z = 0
for i in range(0, len(b)):
	i = b[i]
	m = c - i
	z += m
print(z)


n = int(input())
ar = [int(num) for num in input().split()]
m = max(ar)
e = 0
for i in ar:
	k = m - i
	e = e + k
print(e)


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


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


n = int(input())
result = 0
data = list(map(int, input().split()))
data.sort(reverse=True)
for m in data:
	result = result + data[0] - m
print(result)


population = int(input().strip())
num = [int(x) for x in input().strip().split()]
print(max(num) * population - sum(num))


n = int(input())
a = list(map(int, input().split()))
S = 0
if len(a) == 1:
	S = 0
else:
	max_a = max(a)
	for i in range(n):
		diff = max_a - a[i]
		if diff > 0:
			S += diff
print(S)


n = int(input())
citizens = list(map(int, input().split()))
maximum = 0
money = 0
for i in range(n):
	if citizens[i] > maximum:
		maximum = citizens[i]
for j in range(n):
	money += maximum - citizens[j]
print(money)


def solve(n):
	sums = 0
	max_n = max(n)
	for char in n:
		if char != max_n:
			sums += max_n - char
	return sums
m = input()
data = input()
n = [int(char) for char in data.split(' ')]
print(solve(n))


n = int(input())
ara = [int(i) for i in input().split()]
maxi = 0
for x in ara:
	if x > maxi:
		maxi = x
sum = 0
for x in ara:
	sum = sum + (maxi - x)
print(sum)


from sys import stdin
_input = stdin.readline
(_max, _int) = (max, int)

def solution():
	n = _int(_input())
	arr = [_int(i) for i in _input().split()]
	m = _max(arr)
	ans = 0
	for i in arr:
		ans += m - i
	print(ans)
solution()


n = int(input())
a = [int(i) for i in input().split()]
sum = 0
for k in a:
	sum += k
print(n * int(max(a)) - int(sum))


def welfare_calc():
	n = int(input())
	welfare_scores = [int(x) for x in input().split()]
	max_welfare = max(welfare_scores)
	return sum((max_welfare - score for score in welfare_scores))
print(welfare_calc())


def main():
	from sys import stdin, stdout
	n = int(stdin.readline())
	a = tuple(map(int, stdin.readline().split()))
	maxim = max(a)
	mysum = 0
	for i in a:
		mysum += maxim - i
	stdout.write(str(mysum))
main()


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


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


import sys
import re
import math
import itertools
import collections
import bisect
mod = 1000000007
pi = 3.141592653589793
IS = float('inf')
xy = [(1, 0), (-1, 0), (0, 1), (0, -1)]
bs = [(-1, -1), (-1, 1), (1, 1), (1, -1)]

def niten(a, b):
	return abs(a - b) if a >= 0 and b >= 0 else a + abs(b) if a >= 0 else abs(a) + b if b >= 0 else abs(abs(a) - abs(b))

def fib(n):
	return [(seq.append(seq[i - 2] + seq[i - 1]), seq[i - 2])[1] for seq in [[0, 1]] for i in range(2, n)]

def gcd(a, b):
	return a if b == 0 else gcd(b, a % b)

def lcm(a, b):
	return a * b / gcd(a, b)

def eucl(x1, y1, x2, y2):
	return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5

def choco(xa, ya, xb, yb, xc, yc, xd, yd):
	return 1 if abs((yb - ya) * (yd - yc) + (xb - xa) * (xd - xc)) < 1e-10 else 0

def pscl(num, l=[1]):
	for i in range(num):
		l = map(lambda x, y: x + y, [0] + l, l + [0])
	return l
n = int(input())
l = [int(i) for i in input().split()]
tmp = max(l)
ans = chk = 0
for i in l:
	ans += tmp - i
print(ans)


n = int(input())
a = [int(x) for x in input().split()]
k = max(a)
p = 0
for i in range(len(a)):
	p = p + (k - a[i])
print(p)


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


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


no_citizens = int(input())
welfares = list(map(int, input().split()))
max_welfare = max(welfares)
expense = 0
for welfare in welfares:
	expense += max_welfare - welfare
print(expense)


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


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
N = int(input())
A = [int(x) for x in input().split()]
ma = max(A)
ans = sum([ma - v for v in A])
print(ans)


x = int(input())
b = [int(x) for x in input().split()]
max = 0
sum = 0
for i in b:
	if i > max:
		max = i
for i in b:
	sum += max - i
print(sum)


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


N = int(input())
nums = list(map(int, input().split()))
print(N * max(nums) - sum(nums))


n = int(input())
l = []
for x in input().split():
	l.append(int(x))
a = max(l)
qian = 0
for i in range(n):
	qian += a - l[i]
print(qian)


t = int(input())
lst = list(map(int, input().split()))
p = sum(lst)
q = max(lst)
print(t * q - p)


b = int(input())
a = list(map(int, input().split()))
maxi = max(a)
sum = 0
for i in range(0, len(a)):
	sum += maxi - a[i]
print(sum)


n = int(input())
a = [int(i) for i in input().split()]
v = 0
for i in a:
	v += max(a) - i
print(v)


jonoshongkha = int(input())
sobar_shompod = list(map(int, input().split()))
total_shompod = sum(sobar_shompod)
bill_gates = max(sobar_shompod)
bill_gates_bade_onnoder_shompod = total_shompod - bill_gates
shobaire_bill_gates_banaite_chaile_lagbe = bill_gates * jonoshongkha
taile_short_ache_hoilo = shobaire_bill_gates_banaite_chaile_lagbe - total_shompod
print(taile_short_ache_hoilo)


n = int(input())
burles = [int(i) for i in input().split(' ')]
biggestBurle = max(burles)
print(n * biggestBurle - sum(burles))


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


(n, a) = (int(input()), [int(s) for s in input().split()])
k = 0
a.sort()
a.reverse()
for i in range(len(a)):
	k += a[0] - a[i]
print(k)


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


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


num_citizens = int(input())
welfares = [int(a) for a in input().strip().split()]
welfares.sort()
maximum = welfares[-1]
total = maximum * num_citizens
print(total - sum(welfares))


n = int(input())
s = [int(a) for a in input().split()]
s.sort()
ss = list(reversed(s))
dis = 0
i = 1
while i < len(ss):
	dis = dis + ss[0] - ss[i]
	i = i + 1
print(dis)


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


n = int(input())
count = 0
welfare = list(map(int, input().split(' ')))
if n == 1:
	print(0)
else:
	for i in welfare:
		if i == max(welfare):
			continue
		else:
			count = count + (max(welfare) - i)
	print(count)


import sys
input = sys.stdin.readline

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0, hi=None):
	if hi == None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	m = max(a)
	s = 0
	for x in a:
		s += abs(x - m)
	print(s)
for _ in range(1):
	solve()


n = int(input())
if n > 1:
	ws = [int(x) for x in input().split()]
	m = max(*ws)
	s = 0
	for i in ws:
		s += m - i
	print(s)
else:
	print(0)


n = input()
l = list(map(int, input().split()))
count = 0
_max = max(l)
for i in l:
	count += _max - i
print(count)


n = int(input())
g = [int(a) for a in input().split()]
max = -1
for i in range(n):
	if g[i] > max:
		max = g[i]
s = 0
for i in range(n):
	s += max - g[i]
print(s)


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


n = int(input())
a = list(map(int, input().split(' ')))
x = max(a)
m = map(lambda s: x - s, a)
sum = 0
for q in m:
	sum += q
print(sum)


n = int(input())
myminimum = 0
total = 0
line = [int(x) for x in input().split()]
for citizen in line:
	total += citizen
	if citizen > myminimum:
		myminimum = citizen
print(myminimum * n - total)


n = int(input())
f = list(map(int, input().split(' ')))
f.sort()
s = 0
if n > 1:
	for i in range(0, n - 1):
		if f[i] == f[n - 1]:
			break
		else:
			s = s + f[n - 1] - f[i]
	print(s)
else:
	print(0)


n = int(input())
m = list(map(int, input().split()))
m.sort()
s = list(set(m))
if len(s) == 1:
	print(0)
else:
	print(m[-1] * n - sum(m))


cantidad = int(input())
lista = [int(x) for x in input().split()]
maximo = max(lista)
print(sum([maximo - x for x in lista]))


n = int(input())
arr = list(map(int, input().split()))
mx = max(arr)
print(sum((abs(val - mx) for val in arr)))


noOfCitizens = int(input())
citizens = list(map(int, input().split()))
x = max(citizens)
sum = 0
for j in citizens:
	sum += x - j
print(sum)


n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
if n == 1:
	print('0')
else:
	val = a[n - 1]
	mn = 0
	for i in a[:n - 1]:
		mn += val - i
	print(mn)


n = int(input())
p = list(map(int, input().split()[:n]))
m = max(p)
burle = 0
for i in range(0, len(p)):
	d = abs(p[i] - m)
	burle = burle + d
print(burle)


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


n = int(input())
mx = 0
s = 0
for x in map(int, input().split()):
	mx = max(mx, x)
	s += x
print(mx * n - s)


x = int(input())
y = [int(p) for p in input().split()]
r = 0
m = max(y)
for i in y:
	r = r + (m - i)
print(r)


citizens = int(input())
welfares = input()
welfares = welfares.split()
for i in range(citizens):
	welfares[i] = int(welfares[i])
maxWelfare = welfares[0]
for i in welfares:
	if i > maxWelfare:
		maxWelfare = i
spend = 0
for i in welfares:
	if i < maxWelfare:
		spend += maxWelfare - i
print(spend)


n = int(input())
money_used = 0
money = input().split()
for num in range(n):
	money[num] = int(money[num])
money.sort()
reference = max(money)
for welfare in money:
	money_used += reference - welfare
	welfare = reference
print(money_used)


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


n = int(input())
x = list(map(int, input().split()))
mx = max(x)
dl = sum(map(lambda x: abs(mx - x), x))
print(dl)


n = input()
welfare = input().split(' ')
for i in range(len(welfare)):
	welfare[i] = int(welfare[i])
max1 = max(welfare)
total = 0
for i in welfare:
	total += max1 - i
print(total)


n = int(input())
l = list(map(int, input().split()))
l.sort()
m = l[-1]
c = 0
for i in range(n - 1):
	c = c + (m - l[i])
print(c)


def solve():
	n = int(input())
	mas = [int(s) for s in input().split()]
	max_mas = max(mas)
	ans = 0
	for i in range(n):
		ans += max_mas - mas[i]
	print(ans)
solve()


citizens = int(input())
welfares = [int(x) for x in input().split()]
top = max(welfares)
ans = 0
for i in welfares:
	ans += top - i
print(ans)


n = int(input())
_list = list(map(int, input().split()))
m_list = max(_list)
count = 0
for i in range(n):
	count += m_list - _list[i]
print(count)


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


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


n = int(input())
li = list(map(int, input().split()))
li.sort()
diff = li[-1]
s = 0
if n == 1:
	print(0)
else:
	for i in range(len(li)):
		s += diff - li[i]
	print(s)


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


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


n = input()
l = list((int(x) for x in input().split()))
sum = 0
max = max(l)
for x in l:
	sum += max - x
print(sum)


n = int(input())
l = list(map(int, input().split(' ')))
m_ = max(l)
l = sorted(l)
ind = l.index(m_)
l = l[:ind]
dl = len(l)
s = 0
for i in range(dl):
	s += m_ - l[i]
print(s)


n = int(input())
a = []
a = list(map(int, input().split()))
a.sort()
d = a[n - 1]
m = 0
for i in range(n - 1):
	m = m + (d - a[i])
print(m)


n = int(input())
c = list(map(int, input().split()))
c.sort()
mx = c[-1]
need = 0
for i in c:
	need += mx - i
print(need)


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


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


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


n = int(input())
lst = list(map(int, input().split()))
count = 0
maxx = max(lst)
for i in range(n):
	count += maxx - lst[i]
print(count)


n = int(input())
ln = [int(a) for a in input().split(' ')]
sm = sum(ln)
print(max(ln) * n - sm)


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


n = int(input())
l = list(map(int, input().split()))
max1 = max(l)
l = [x - max1 for x in l]
print(abs(sum(l)))


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


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


t = int(input())
ar = [int(i) for i in input().split()]
print(t * max(ar) - sum(ar))


from fractions import gcd
from heapq import *
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7

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


n = int(input())
k = list(map(int, input().strip().split()[:n]))
m = max(k)
c = 0
for x in k:
	if x != m:
		c = c + m - x
print(c)


input()
a = [int(x) for x in input().split()]
m = max(a)
t = 0
for x in a:
	t += m - x
print(t)


n = int(input())
x = input().split()
for i in range(n):
	x[i] = int(x[i])
x.sort()
c = 0
for j in range(n):
	c += x[n - 1] - x[j]
print(c)


N = int(input())
x = [i for i in input().split(' ')]
chars = []
for i in x:
	chars.append(i)
chars.sort()
for i in range(0, len(chars)):
	chars[i] = int(chars[i])
d = max(chars)
b = 0
c = 0
chars.remove(d)
for i in range(0, len(chars)):
	b = d - int(chars[i])
	c = c + b
print(c)


x = int(input())
a = [int(s) for s in input().split()]
g = 0
m = max(a)
a.pop(a.index(m))
m1 = m * len(a)
for i in range(len(a)):
	g = g + a[i]
print(m1 - g)


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


a = input()
b = [int(x) for x in input().split()]
base = int(0)
output = int(0)
for i in b:
	if i > base:
		base = i
for i in b:
	if base > int(i):
		output += base - i
print(output)


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


number_of_citizens = int(input())
money = sorted([int(i) for i in input().split()])
output = 0
for i in range(0, len(money) - 1):
	output += money[-1] - money[i]
print(output)


n = int(input())
a = list(map(int, input().split()))
if len(a) == 0 or len(a) == 1:
	print(0)
else:
	a = sorted(a)
	x = 0
	for i in range(n - 1):
		x += abs(a[n - 1] - a[i])
	print(x)


import sys
n = int(input())
list1 = [int(x) for x in input().split()]
if n == 1:
	print(0)
	sys.exit(0)
temp = max(list1)
counter = 0
for i in list1:
	counter += temp - i
print(counter)


def solve(p):
	maxval = max(p)
	amount = 0
	for i in p:
		amount += maxval - i
	return amount
n = int(input())
p = [int(x) for x in input().split(' ')]
print(solve(p))


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


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


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


x = int(input())
y = list(map(int, input().split()))
jk = max(y)
ans = 0
for i in y:
	if i < jk:
		ans += jk - i
	else:
		pass
print(ans)


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


size = int(input())
l = list(map(int, input().split()))
m = max(l)
for i in range(size):
	l[i] = m - l[i]
print(sum(l))


q = int(input(''))
w = input('').split()
m = 1
t = 0
s = int(w[0])
for r in range(q - 1):
	if s < int(w[m]):
		s = int(w[m])
	m = m + 1
m = 0
for rq in range(q):
	t = t + (s - int(w[m]))
	m = m + 1
print(t)


t = int(input())
a = list(map(int, input().split()))
c = max(a)
a.remove(c)
summ = 0
for i in range(len(a)):
	summ = summ + c - a[i]
print(summ)


n = int(input())
a = [int(i) for i in input().split()]
mx = max(a)
s = 0
for num in a:
	s += mx - num
print(s)


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


n = int(input())
l = list(map(int, input().split()))
l.sort()
a = l[n - 1]
count = 0
for i in range(n - 1):
	m = a - l[i]
	count = count + m
print(count)


n = int(input())
x = [int(x) for x in input().split()]
p = max(x)
sum = 0
for i in range(n):
	sum += x[i]
print(p * n - sum)


n = int(input())
welfaers = tuple((int(i) for i in input().split()))
max_welfaer = max(welfaers)
answer = n * max_welfaer - sum(welfaers)
print(answer)


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


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


n = input()
inp = input().split()
inp = [int(x) for x in inp]
(bign, s) = (max(inp), 0)
for i in inp:
	if i != bign:
		b = bign - i
		s += b
print(s)


n = int(input())
list1 = list(map(int, input().split()))
(max, count) = (max(list1), 0)
for item in list1:
	count += max - item
print(count)


step = int(input())
people = [int(i) for i in input().split()]
goal = max(people)
k = 0
for i in people:
	if i < goal:
		k += goal - i
print(k)


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


n = int(input())
m = list(map(int, input().split()))
b = 0
mx = max(m)
for i in range(n):
	b += mx - m[i]
print(b)


q = input()
n = input()
d = []
s = ''
for i in range(len(n)):
	if n[i] == ' ':
		d.append(int(s))
		s = ''
		continue
	else:
		s += n[i]
d.append(int(s))
max = d[0]
for i in range(len(d)):
	if max < d[i]:
		max = d[i]
rezult = 0
for i in range(len(d)):
	rezult += max - d[i]
print(rezult)


n = input()
money = list(map(int, input().split()))
mx = max(money)
kings_money = 0
for each in money:
	kings_money += mx - each
print(kings_money)


n = input()
n = int(n)
arr = input().split(' ')
s = 0
temp = 0
for (i, val) in enumerate(arr):
	a = int(val)
	if temp < a:
		if i != 0:
			s += (a - temp) * i
		temp = a
	elif temp > a:
		s += temp - a
print(s)


n = int(input())
ls = list(map(int, input().split()))
mx = 0
for i in ls:
	if i > mx:
		mx = i
res = 0
for i in ls:
	res += mx - i
print(res)


def solve(welfare, n):
	maxWelfare = welfare[0]
	for i in range(1, n):
		maxWelfare = max(welfare[i], maxWelfare)
	burlesNeeded = 0
	for i in range(0, n):
		burlesNeeded += maxWelfare - welfare[i]
	return burlesNeeded
n = int(input())
welfare = input().split(' ')
welfare = [int(i) for i in welfare]
print(solve(welfare, n))


def solve(arr):
	m = max(arr)
	return sum(map(lambda x: m - x, arr))

def main():
	n = input()
	arr = list(map(int, input().split()))
	print(solve(arr))
main()


def burle(inp):
	max_ele = max(inp)
	count = 0
	for i in inp:
		count += max_ele - i
	return count

def main():
	t = int(input())
	numbers = [int(n) for n in input().split()]
	print(burle(numbers))
main()


x = int(input())
lyst = [int(i) for i in input().split(' ')]
lyst.sort()
counter = 0
for k in range(2, len(lyst) + 1):
	x = lyst[-1] - lyst[-k]
	counter += x
print(counter)


people = int(input())
money_people = [int(x) for x in input().split()]
trats_king = max(money_people) * people - sum(money_people)
print(trats_king)


n = int(input())
a = [int(i) for i in input().split()]
amax = max(a)
ans = 0
for elem in a:
	ans += amax - elem
print(ans)


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


n = int(input())
x = [int(y) for y in input().split()]
c = 0
k = max(x)
for i in x:
	c += k - i
print(c)


n = int(input())
x = [int(i) for i in input().split()]
max = 0
sum = 0
for i in range(n):
	if x[i] > max:
		max = x[i]
for i in range(n):
	if x[i] < max:
		z = max - x[i]
		sum += z
print(sum)


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


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


from typing import List, Tuple

def parse_input() -> Tuple[int, List[int]]:
	return (int(input()), [int(x) for x in input().split()])

def solve(n: int, a: List[int]) -> int:
	m = max(a)
	return sum([m - elem for elem in a])
(n, a) = parse_input()
print(solve(n, a))


n = int(input())
sum = 0
a = sorted(list(map(int, input().split())), reverse=True)
for i in range(1, n):
	sum += a[0] - a[i]
print(sum)


n = int(input())
(s, m) = (0, 0)
a = [int(n) for n in input().split(' ')]
f = max(a)
for i in range(len(a)):
	m = f - a[i]
	s = s + m
print(s)


import sys
n = int(input())
p = [int(i) for i in input().split()]
m = max(p)
w = 0
for e in p:
	w += m - e
print(w)


n = int(input())
a = [int(i) for i in input().split()]
b = a[0]
res = 0
for i in a:
	if i > b:
		b = i
for i in a:
	if i < b:
		res += b - i
print(res)


def codeforces(citizens):
	result = 0
	for citizen in citizens:
		result += max(citizens) - citizen
	return result
_ = input()
citizens = list(map(int, input().split()))
print(codeforces(citizens))


n = int(input())
l = sorted(list(map(int, input().split())))
i = 0
k = 0
while True:
	if len(set(l)) == 1:
		break
	x = max(l) - l[i]
	l[i] += x
	k += x
	i += 1
print(k)


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


n = int(input())
total = 0
l = list(map(int, input().strip().split()))
maxi = max(l)
for i in l:
	total += maxi - i
print(total)


n = int(input())
arr = list(map(int, input().split()))
sum = 0
max = -1
for i in range(0, n):
	if arr[i] > max:
		max = arr[i]
for i in range(0, n):
	sum = sum + (max - arr[i])
print(sum)


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


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


num = int(input())
inp = input().split()
for i in range(num):
	inp[i] = int(inp[i])
inp.sort()
compare = inp[-1]
sumput = 0
for i in inp:
	sumput += compare - i
print(sumput)


n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
d = max(a)
count = 0
for j in range(len(a)):
	count = count + (d - a[j])
print(count)


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


def main():
	try:
		while True:
			n = int(input())
			a = list(map(int, input().split()))
			m = max(a)
			print(sum((m - x for x in a)))
	except EOFError:
		pass
main()


p = input()
m = list(map(int, input().split()))
mm = max(m)
c = 0
for i in m:
	i = mm - i
	c = c + i
print(c)


num_of_citizens = int(input())
welfare = [*map(int, input().split())]
threshold = max(welfare)
required_amount = num_of_citizens * threshold - sum(welfare)
print(required_amount)


a = int(input())
b = list(map(int, input().split(' ')))
c = max(b)
s = 0
for i in b:
	s = s + (c - i)
print(s)


n = int(input())
nums = list(map(int, input().split()))
nums.sort()
total = 0
for i in nums:
	total += nums[len(nums) - 1] - i
print(total)


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


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


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


def main():
	n = int(input())
	list1 = list(map(int, input().split(' ')))
	max1 = max(list1)
	sum1 = 0
	for i in list1:
		sum1 += max1 - i
	print(sum1)
main()


import sys

def solve():
	n = input()
	arr = [int(x) for x in input().split(' ')]
	richest = max(arr)
	ans = 0
	for i in arr:
		ans += richest - i
	return ans
ans = solve()
print(ans)


n = int(input())
l = list(map(int, input().split()))
max = max(l)
b = 0
for i in range(0, n):
	if max - l[i] > 0:
		b += max - l[i]
print(b)


number = int(input())
s = input()
l = s.split()
for i in range(0, number):
	l[i] = int(l[i])
l.sort()
max_number = l[number - 1]
sum = 0
for i in range(0, number):
	sum = sum + (max_number - l[i])
print(sum)


n = int(input())
x = sorted(map(int, input().split()))
sum = 0
for i in range(0, n - 1):
	sum += x[n - 1] - x[i]
print(sum)


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


n = int(input())
I = [int(i) for i in input().split()]
for i in range(len(I)):
	for j in range(len(I)):
		if I[i] < I[j]:
			(I[i], I[j]) = (I[j], I[i])
(k, count) = (I[-1], 0)
for i in range(len(I)):
	count += k - I[i]
print(count)


import sys
n = int(input())
l = list(map(int, input().split()))
if n == 1:
	print(0)
	sys.exit(0)
(m, c) = (max(l), 0)
for i in l:
	if i == m:
		continue
	c = c + (m - i)
print(c)


no = int(input())
num = []
num = list(map(int, input().split()))
largest = num[0]
for i in range(0, len(num)):
	if num[i] > largest:
		largest = num[i]
count = 0
for i in range(no):
	count = count + (largest - num[i])
if no == 1:
	print('0')
else:
	print(count)


a = int(input())
b = list(map(int, input().split()))
c = max(b)
d = 0
for i in range(a):
	d += c - b[i]
print(d)


n = int(input())
l = list(map(int, input().split()))
max_l = l[0]
for i in range(1, n):
	max_l = max(l[i], max_l)
m = 0
for i in range(0, n):
	m += max_l - l[i]
print(m)


n = int(input())
arr = list(map(int, input().split()))
maxi = 0
for i in range(0, n):
	if arr[i] > maxi:
		maxi = arr[i]
ans = 0
for i in range(0, n):
	ans = ans + (maxi - arr[i])
print(ans)


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


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


n = int(input())
a = [int(x) for x in input().split(' ')]
maxa = max(a)
print(sum((maxa - x for x in a)))


n = int(input())
a = sorted(list(map(int, input().split())))
cnt = 0
for i in range(n):
	if a[-1] != a[i]:
		cnt += a[-1] - a[i]
print(cnt)


n = int(input())
arr = list(map(int, input().split()))
j = max(arr)
arr2 = []
for i in arr:
	arr2.append(j - i)
print(sum(arr2))


n = int(input())
s = input()
welfare = s.split(' ')
for i in range(0, n):
	welfare[i] = int(welfare[i])
max = welfare[0]
for i in range(1, n):
	if max < welfare[i]:
		max = welfare[i]
ans = 0
for i in range(0, n):
	ans += max - welfare[i]
print(ans)


x = int(input())
y = input().split()
emon = []
for i in y:
	m = int(i)
	emon.append(m)
emon.sort()
max = emon[-1]
bar = 0
for i in range(len(emon) - 1):
	bar = bar + (max - emon[i])
print(bar)


n = int(input())
L = list(map(int, input().split()))
sum_ = 0
X = max(L)
for each in L:
	sum_ += X - each
print(sum_)


n = int(input())
a = [int(i) for i in input().split()]
s = 0
b = []
d = max(a)
for i in range(len(a)):
	if a[i] < d:
		s += d - a[i]
print(s)


def burles(b):
	burl = 0
	if len(b) == 1:
		return 0
	else:
		equal = max(b)
		for i in b:
			burl += equal - i
	return burl
n = int(input())
s = list(map(int, input().split()))
res = burles(s)
print(res)


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


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


n = input()
n = int(n)
every_money = input().split()
if n == 0:
	total_money = 0
else:
	total_money = 0
	for i in range(n):
		every_money[i] = int(every_money[i])
	for m in range(n):
		total_money += max(every_money) - every_money[m]
print(total_money)


n = int(input())
mo = 0
x = list(map(int, input().split()))
w = sorted(x, reverse=True)
ex = 0
while n != 1:
	if x[ex] < w[0]:
		mo += w[0] - x[ex]
	ex += 1
	if ex == len(x):
		break
print(mo)


def main():
	n = int(input())
	ary = [int(i) for i in input().split()]
	maximum = max(ary)
	sum = 0
	for e in ary:
		sum += maximum - e
	print(sum)
main()


t = int(input())
r = 0
s = input()
n = [int(s) for s in s.split()]
l = max(n)
for i in range(t):
	r += l - n[i]
print(r)


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


a = int(input())
s = sorted(list(map(int, input().split())))
b = 0
for i in range(a):
	c = s[a - 1] - s[i]
	b += c
print(b)


x = int(input())
y = [int(a) for a in input().split()]
m = max(y)
i = y.index(m)
del y[i:i + 1]
s = 0
for i in y:
	s += m - i
print(s)


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


n = int(input())
ai = [int(elt) for elt in input().split(' ')]
x = max(ai)
res = 0
for elt in ai:
	res += x - elt
print(res)


t = input('')
a = sorted([int(i) for i in input('').split(' ')])
print(sum((max(a) - x for x in a[:-1])))


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


inp = input
li = list
iinp = lambda : int(inp())
ent = lambda : map(int, inp().split())
lient = lambda : [int(i) for i in inp().split()]
li0 = lambda x: [0 for i in range(x)]
n = iinp()
din = lient()
res = 0
maxi = max(din)
for i in din:
	res += maxi - i
print(res)


n = int(input())
s = list(map(int, input().split()))
ans = 0
for i in range(n):
	s = sorted(s)
	t = s[-1] - s[0]
	ans += t
	s.pop(0)
print(ans)


n = int(input())
l = [int(x) for x in input().split()]
ma = max(l)
re = 0
for i in l:
	re += ma - i
print(re)


import sys
from sys import stdin, stdout
import bisect
import math
import heapq

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
import math

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def most_frequent(list):
	return max(set(list), key=list.count)

def GCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def main():
	n = inin()
	q = ain()
	count = 0
	for i in range(len(q)):
		count = count + (max(q) - q[i])
	print(count)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'0'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'0'[0]:
		A.append(sign * numb)
	return A
main()


n = int(input())
m = [int(i) for i in input().split()]
maxn = max(m)
print(sum([maxn - i for i in m]))


n = input()
x = input().split(' ')
zx = []
for el in x:
	zx.append(int(el))
max_ = max(zx)
g = 0
for el in zx:
	g += max_ - el
print(g)


num_citizens = int(input())
welfare = input().split()
welfare = map(int, welfare)
welfare = list(welfare)
welfare = sorted(welfare)
max_welfare = welfare[-1]
count = 0
for i in range(num_citizens):
	if welfare[i] == max_welfare:
		continue
	else:
		count += max_welfare - welfare[i]
print(count)


n = int(input())
a = list(map(int, input().split()))
a.sort()
c = 0
for i in range(n):
	c += a[n - 1] - a[i]
print(c)


def max(li):
	mx = 0
	for j in li:
		if j > mx:
			mx = j
	return mx
n = int(input())
l = list(map(int, input().split()))
m = max(l)
c = 0
for i in l:
	c += m - i
print(c)


n = int(input())
arr = list(map(int, input().strip().split()))
arr.sort()
c = 0
for i in range(n):
	c += arr[n - 1] - arr[i]
print(c)


n = int(input())
s = input().split()
m = None
sum = 0
for i in s:
	if m is None or int(i) > m:
		m = int(i)
m = int(m)
for i in s:
	sum = sum + (m - int(i))
print(sum)


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


n = int(input())
x = [int(n) for n in input().split()]
num = max(x)
cost = 0
for i in range(n):
	if x[i] < num:
		cost = cost + (num - x[i])
print(cost)


x = int(input())
y = input().split()
high = 0
num = 0
cur = 0
for i in y:
	i = int(i)
	if i > high:
		cur += (i - high) * num
		high = i
	elif i < high:
		cur += high - i
	num += 1
print(cur)


a = []
while True:
	try:
		a.append(input())
	except:
		break
m = 0
k = 0
g = a[1].split(' ')
n = int(a[0])
for i in range(n):
	k += int(max(g, key=lambda x: int(x))) - int(g[i])
print(k)


n = int(input())
l = [int(i) for i in input().split()]
k = max(l)
cnt = 0
for i in l:
	cnt = cnt + k - i
print(cnt)


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


x = input()
x2 = input().split()
high = int(x2[0])
cost = 0
for i in range(len(x2)):
	x2[i] = int(x2[i])
	if x2[i] > high:
		high = x2[i]
for i in range(len(x2)):
	cost += high - x2[i]
print(cost)


n = int(input())
h = list(map(int, input().split()))
max_h = max(h)
count = 0
for i in range(n):
	if h[i] < max_h:
		r = max_h - h[i]
		count += r
print(count)


n = int(input())
arr = list(map(int, input().split()))
maxi = max(arr)
print(sum(map(lambda x: maxi - x, arr)))


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


n = input()
b = input()
wel1 = b.split()
wel = []
for i in wel1:
	wel.append(int(i))
ma = max(wel)
sum = 0
for i in wel:
	sum += ma - i
print(sum)


n = int(input())
list1 = list(map(int, input().split()))
count = 0
for m in range(n):
	count += list1[m]
print(n * max(list1) - count)


n = input()
a = list(map(int, input().split()))
m = max(a)
s = sum(map(lambda x: m - x, a))
print(s)


n = int(input())
l = list(map(int, input().split()))
m = max(l)
burles = 0
for _ in l:
	if _ != m:
		burles += m - _
print(burles)


n = int(input())
li = list(map(int, input().split()))
res = 0
k = max(li)
for i in li:
	res += k - i
print(res)


n = int(input())
b = [int(i) for i in input().split()]
k = max(b)
it = 0
for i in range(len(b)):
	it += int(k) - int(b[i])
print(it)


n = int(input())
a = [int(x) for x in input().split()]
x = max(a)
v = 0
for i in range(len(a)):
	v += x - a[i]
print(v)


n = int(input())
a = list(map(int, input().strip().split(' ')))
s = sum(a[:])
m = max(a)
print(m * n - s)


n = int(input())
coins = [int(i) for i in input().split()]
max1 = max(coins)
res = 0
for i in coins:
	res += max1 - i
print(res)


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


from functools import reduce
n = int(input())
a = input().split()
aMax = reduce(max, map(int, a))
print(sum([aMax - int(i) for i in a]))


__author__ = 'artyom'

def main():
	n = read()
	a = read(3)
	x = max(a)
	s = 0
	for v in a:
		s += x - v
	return s

def read(mode=1, size=None):
	if mode == 0:
		return input().strip()
	if mode == 1:
		return int(input().strip())
	if mode == 2:
		return input().strip().split()
	if mode == 3:
		return list(map(int, input().strip().split()))
	a = []
	for _ in range(size):
		a.append(read(3))
	return a

def write(s='\n'):
	if s is None:
		s = ''
	if isinstance(s, tuple) or isinstance(s, list):
		s = ' '.join(map(str, s))
	s = str(s)
	print(s, end='\n')
write(main())


a = int(input())
l = list(map(int, input().split(' ')))
sum1 = 0
b = max(l)
for i in range(a):
	c = 0
	if l[i] == b:
		continue
	else:
		c = abs(l[i] - b)
		sum1 += c
print(sum1)


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


n = int(input())
a = [int(x) for x in input().split()]
maximal = max(a)
burles = 0
for x in a:
	burles += maximal - x
print(burles)


n = int(input())
l = list(map(int, input().split()))[:n]
ma = max(l)
s = sum(l)
count = ma * n - s
print(count)


n = int(input())
a = list(map(int, input().split()))
print([0, max(a) * n - sum(a)][n > 1])


n = int(input())
l = list(map(int, input().split()))
l.sort()
sum = 0
for i in range(n):
	if l[i] < l[n - 1]:
		sum += l[n - 1] - l[i]
print(sum)


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


n = input()
a = [int(i) for i in input().split(' ')]
maxVal = max(a)
result = sum(map(lambda x: maxVal - x, a))
print(result)


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


n = int(input())
arr = list(map(int, input().split(' ')))
spend = 0
high = max(arr)
for item in arr:
	spend += high - item
print(spend)


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


n = int(input())
welfare = list(map(int, input().split()))
richest = max(welfare)
s = 0
for i in welfare:
	if i < richest:
		s += richest - i
print(s)


def Main():
	n = int(input())
	cits = list(map(int, input().split()))
	cits.sort()
	ans = 0
	for i in range(n - 1):
		ans += cits[n - 1] - cits[i]
	print(ans)
Main()


n = int(input())
arr = list(map(int, input().split()))
arr1 = sorted(arr)
k = max(arr)
r = []
l = len(arr)
for i in range(l - 1):
	r.append(k - arr1[i])
print(sum(r))


i = int(input())
if i not in range(1, 101):
	exit(0)
inp = tuple(map(int, input().split()))
mx = 0
for x in range(i):
	if inp[x] not in range(0, 10 ** 6 + 1):
		exit(0)
	if inp[x] > mx:
		mx = inp[x]
ttl = 0
for x in range(i):
	ttl += mx - inp[x]
print(ttl)


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


a = int(input())
b = list(map(int, input().split()))
c = max(b)
r = []
for i in b:
	r.append(c - i)
print(sum(r))


n = int(input())
citizen = list(map(int, input().split()))
mx = max(citizen)
ans = sum(map(lambda x: mx - x, citizen))
print(ans)


n = int(input())
spisok = list(map(int, input().split()))
maximum = max(spisok)
sum = 0
for i in range(n):
	sum += maximum - spisok[i]
print(sum)


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


def main():
	n = input()
	vals = [int(v) for v in input().split()]
	m = max(vals)
	print(sum([m - v for v in vals]))
main()


n = int(input())
k = -1
c = [0] * n
j = 0
a = [int(i) for i in input().split()]
for i in range(0, n):
	if a[i] > k:
		k = a[i]
for i in range(0, n):
	if a[i] == k:
		pass
	else:
		c[i] = k - a[i]
		j += c[i]
print(j)


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


import pdb
_ = int(input())
(*n,) = map(int, input().split())
x = max(n)
y = x * (len(n) - 1)
z = sum(sorted(n)) - x
print(y - z)


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


n = int(input())
arr = [int(i) for i in input().split()]
arr.sort()
ans = 0
for i in range(n - 1):
	ans += abs(arr[i] - arr[n - 1])
print(ans)


n = int(input())
a = [int(i) for i in input().split(' ')]
print(max(a) * len(a) - sum(a))


n = int(input())
l = list(map(int, input().split()))
l.sort()
val = l[-1]
ans = 0
for i in l:
	ans += val - i
print(ans)


num = int(input())
mls = input()
m = 0
res = 0
mls = mls.split(' ')
for i in range(num):
	mls[i] = int(mls[i])
	if mls[i] > m:
		m = mls[i]
for i in range(num):
	res += m - mls[i]
print(res)


n = int(input())
w = [int(x) for x in input().split(' ')]
w.sort()
count = 0
i = 0
while i < n - 1:
	if w[i] == w[n - 1]:
		break
	count += w[n - 1] - w[i]
	i += 1
print(count)


k = int(input())
g = input()
g = g.split()
z = int(g[0])
o = 1
for r in range(k - 1):
	if z < int(g[o]):
		z = int(g[o])
	o = o + 1
o = 0
l = 0
for b in range(k):
	o = o + z - int(g[l])
	l = l + 1
print(o)


n = int(input())
a = [int(i) for i in input().strip().split(' ')]
a_max = max(a)
total = 0
for i in a:
	total += a_max - i
print(total)


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


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


num_cit = int(input())
cits = list(map(int, input().split()))
cits.sort()
print(max(cits) * (len(cits) - 1) - sum(cits[0:-1]))


import math
n = int(input())
inp = list(map(int, input().split()))
inp.sort(reverse=True)
c = int(inp[0])
d = 0
for i in range(1, n):
	d = d + c - inp[i]
print(d)


n = int(input())
g = []
s = 0
for i in range(n):
	a = map(int, input().split())
	g += a
	break
b = max(g)
for k in g:
	z = b - k
	s += z
print(s)


n = int(input())
lst = list(map(int, input().split()))
res = 0
maxi = max(lst)
for item in lst:
	res += maxi - item
print(res)


x = int(input())
lst = [int(i) for i in input().split()]
count = 0
for i in range(len(lst)):
	count = max(lst) - lst[i] + count
print(count)


from functools import reduce
n = int(input())
print((lambda t: n * t[1] - t[0])(reduce(lambda x, y: (x[0] + y[0], max(x[1], y[1])), [(x, x) for x in list(map(int, input().split()))])))


def solve(list1, n):
	maxx = max(list1)
	c = 0
	for i in range(n):
		c += maxx - list1[i]
	return c
list1 = []
n = int(input())
x = map(int, input().split(' '))
for i in x:
	list1.append(i)
print(solve(list1, n))


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


n = int(input())
a = list(map(int, input().split()))
b = sum(a)
c = max(a)
if n == 1:
	print('0')
else:
	print(c * n - b)


input()
money = list(map(int, input().split()))
maxi = max(money)
money.remove(maxi)
summ = 0
for item in money:
	summ = summ + (maxi - item)
print(summ)


n = int(input())
li = [int(i) for i in input().split()]
li.sort(reverse=True)
s = 0
for i in range(1, len(li)):
	s = s + li[0] - li[i]
print(s)


n = int(input())
burles_list = list(map(int, input().split(' ')))
max_element = max(burles_list)
min_burles = 0
for each_element in burles_list:
	min_burles += max_element - each_element
print(min_burles)


n = int(input())
data = [int(x) for x in input().split()]
temp = [max(data) - data[i] for i in range(len(data)) if data[i] < max(data)]
print(sum(temp))


n = int(input())
s = input()
s = [int(x) for x in s.split(' ')]
s.sort()
c = 0
for k in range(0, n - 1):
	c = c + (s[-1] - s[k])
print(c)


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


def answer():
	n = int(input())
	b = input().split()
	b = [int(x) for x in b]
	ans = 0
	targ = max(b)
	for x in b:
		ans += max(b) - x
	return ans
print(answer())


from sys import stdin
i = [[int(y) for y in x.rstrip().split()] for x in stdin.readlines()][1]
m = max(i)
print(sum((m - x for x in i)))


n = int(input())
report = list(map(int, input().split()))
the_richest = max(report)
count = 0
for i in report:
	count += the_richest - i
print(count)


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())
arr = list(map(int, input().split()))
maxi = max(arr)
cnt = 0
for num in arr:
	cnt += maxi - num
print(cnt)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
n = inp()
a = inlt()
maxcap = max(a)
total = 0
for i in a:
	total += maxcap - i
print(total)


n = int(input())
burles = [int(x) for x in input().split()]
m = max(burles)
total_moves = 0
for b in burles:
	if b < m:
		total_moves += m - b
print(total_moves)


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


n = int(input())
l = list(map(int, input().split()))
maxn = 0
for r in l:
	if int(r) > maxn:
		maxn = int(r)
ans = 0
for u in l:
	ans += maxn - int(u)
print(ans)


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


n = int(input())
people = list(map(int, input().split()))
exp = max(people)
money = [exp - each for each in people]
ans = sum(money)
print(ans)


x = int(input())
l = list(map(int, input().split()))
s = 0
for i in l:
	s += abs(max(l) - i)
print(s)


def equality(n):
	return len(n) * max(n) - sum(n)
nn = int(input())
aa = list(map(int, input().split()))
print(equality(aa))


n = int(input())
result = [int(item) for item in input().split()]
m = max(result)
s = 0
for i in result:
	if i <= m:
		s += m - i
print(s)


n = int(input())
a = [int(x) for x in input().split()]
mval = max(a)
r = 0
for i in range(len(a)):
	r += abs(a[i] - mval)
print(r)


n = int(input())
p = list(map(int, input().strip().split()))
sor = sorted(p)
t = 0
for i in range(0, n - 1):
	dif = sor[n - 1] - sor[i]
	t = t + dif
print(t)


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


a = int(input())
c = map(int, input().split())
b = sorted(c)
x = []
for i in b:
	x.append(b[len(b) - 1] - i)
print(sum(x))


n = int(input())
arr = [int(x) for x in input().split()]
sum1 = sum(arr)
arr.sort()
pro = arr[n - 1] * n
sum2 = pro - sum1
print(sum2)


n = int(input())
l = [int(x) for x in input().split()]
l = sorted(l)
ans = 0
maximum = l[-1]
for i in l[:-1]:
	ans += maximum - i
print(ans)


n = int(input())
l = list(map(int, input().split()))
total = 0
ma = max(l)
for i in l:
	total += ma - i
print(total)


n = int(input())
s = 0
arr = [int(n) for n in input().split()]
c = max(arr)
if n == 1:
	print('0')
else:
	for i in range(len(arr)):
		if c > arr[i]:
			s = s + (c - arr[i])
		else:
			continue
	print(s)


i = input
n = int(i())
l = [*map(int, input().split())]
print(n * max(l) - sum(l))


nStr = input()
n = int(nStr)
aList = list(map(int, input().split()))
topV = max(aList)
total = 0
for i in range(n):
	total = total + (topV - aList[i])
print(total)


n = int(input())
a = list(map(int, input().split()))
sum = 0
a.sort()
if n == 1:
	print(0)
else:
	for i in range(n - 1):
		sum += a[n - 1] - a[i]
	print(sum)


n = int(input())
preciso = [int(x) for x in input().split()]
maax = int(max(preciso))
eq = 0
falta = 0
for x in range(len(preciso)):
	if preciso[x] < maax:
		falta = maax - preciso[x]
		eq += falta
print(eq)


n = int(input())
k = list(map(int, input().split()))
s = max(k)
c = 0
for e in k:
	c += s - e
print(c)


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


n = int(input())
m = [int(x) for x in input().split(' ')]
if len(m) > 1:
	max_s = max(m)
	count = 0
	for i in range(n):
		count += max_s - m[i]
else:
	count = 0
print(count)


a = int(input())
b = list(map(int, input().split()))
b.sort(reverse=True)
c = b.pop(0)
d = 0
if len(b) == 0:
	print(0)
else:
	for j in b:
		if j != c:
			e = c - j
			d += e
		else:
			continue
	print(d)


input()
res = 0
l = [int(x) for x in input().split()]
for x in l:
	res += max(l) - x
print(res)


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


n = int(input())
x = list(map(int, input().strip().split()))
k = max(x)
c = 0
for i in x:
	if i < k:
		c = k - i + c
if len(x) == 1:
	print(0)
else:
	print(c)


n = int(input())
ctzn = list(map(int, input().split()))
ctzn.sort()
boro = ctzn[n - 1]
ans = 0
for i in range(n - 1):
	ans = ans + (boro - ctzn[i])
print(ans)


n = int(input())
inpstr = input()
ai = [int(i) for i in inpstr.split()]
ref_ai = max(ai)
summ = 0
for i in ai:
	summ = summ + (ref_ai - i)
print(summ)


n = int(input())
li = [int(i) for i in input().split()]
max = li[0]
for i in li:
	if i > max:
		max = i
sum = 0
for j in li:
	sum = sum + (max - j)
print(sum)


n = int(input())
li = list(map(int, input().split()))
count = 0
if len(li) == 1:
	print('0')
elif len(li) > 1:
	for i in range(0, len(li)):
		if li[i] == max(li):
			x = i
	for j in range(0, len(li)):
		if j != x and li[j] < li[x]:
			count = count + li[x] - li[j]
	print(count)


import sys
n = int(input())
an = list(map(int, sys.stdin.readline().split()))
m = max(an)
ans = 0
for a in an:
	ans += m - a
print(ans)


input_s = int(input())
input_l = input().split(' ')
max_num = -1
amount = 0
for l in input_l:
	num_l = int(l)
	max_num = max(num_l, max_num)
	amount += num_l
result = max_num * input_s - amount
print(result)


n = int(input())
money = list(map(int, input().split()))
richest = -1
budget = 0
for x in money:
	if x > richest:
		richest = x
for y in range(n):
	if money[y] != richest:
		budget += richest - money[y]
print(budget)


num = int(input())
holding_list = [int(x) for x in input().split()]
new_list = sorted(holding_list)
largest = int(new_list[-1])
count = 0
for num in holding_list:
	count += int(largest) - int(num)
print(count)


n = int(input())
List = [int(j) for j in input().split(' ')]
count = 0
Max = max(List)
for i in range(n):
	count += Max - List[i]
print(count)


input()
a = list(map(int, input().split()))
mx = max(a)
print(sum(map(lambda x: mx - x, a)))


import math
n = int(input())
a = input().split()
maxs = 0
summ = 0
for i in range(len(a)):
	a[i] = int(a[i])
	if a[i] > maxs:
		maxs = a[i]
for i in range(len(a)):
	summ = summ + (maxs - a[i])
print(summ)


from collections import defaultdict

def main():
	n = int(input())
	welfare = list(map(int, input().split()))
	print(len(welfare) * max(welfare) - sum(welfare))
main()


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


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


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


n = int(input())
a = map(int, input().split())
l = []
for i in a:
	l.append(i)
mx = max(l)
sum = 0
for j in l:
	sum = sum + (mx - j)
print(sum)


def main():
	n = int(input())
	l = [int(x) for x in map(int, input().split())]
	s = 0
	m = max(l)
	for i in range(n):
		d = l[i]
		s += m - d
	print(s)
main()


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


numCit = int(input())
welfare = input()
welfare = [int(i) for i in welfare.split(' ')]
maximum = max(welfare)
add = 0
for i in range(numCit):
	add += int(welfare[i])
S = numCit * maximum - add
print(S)


n = int(input())
vals = [*map(int, input().split())]
m = max(vals)
res = 0
if n > 1:
	for i in vals:
		res += m - i
print(res)


int(input())
l = sorted(list(map(int, input().split())))
print(sum([l[len(l) - 1] - i for i in l]))


n = int(input())
a = list(map(int, input().split()))
maxWelfare = max(a)
minBurles = list(map(lambda x: maxWelfare - x, a))
print(sum(minBurles))


n = int(input())
l = list(map(int, input().split()))
k = 0
for i in range(n):
	if l[i] > k:
		k = l[i]
s = 0
for i in range(n):
	s = s + (k - l[i])
print(s)


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


input()
arr = list(map(int, input().split()))
ma = max(arr)
sum = 0
for _ in arr:
	sum += ma - _
print(sum)


import math
import os
import random
import re
import sys
n = int(input())
l = list(map(int, input().rstrip().split()))
a = max(l)
m = [a - x for x in l]
s = sum(m)
print(s)


p = int(input())
k = list(map(int, input().split()))
maxi = max(k)
for i in range(len(k)):
	k[i] = maxi - k[i]
print(sum(k))


n = int(input().strip())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
s = 0
delta = 0
last = a[0]
for i in range(1, n):
	if a[i] == last:
		s += delta
	else:
		last = a[i]
		delta = a[0] - a[i]
		s += delta
print(s)


n = int(input())
l = [int(i) for i in input().split()]
m = max(l)
print(n * m - sum(l))


n = int(input())
lst = list(map(int, input().split()))
mul = max(lst)
add = sum(lst)
print('%d' % (mul * n - add))


k = int(input())
a = [int(x) for x in input().split()]
f = max(a)
if k == 1:
	print('0')
else:
	y = 0
	for i in range(len(a)):
		y += f - a[i]
	print(y)


import sys

def main():
	n = int(sys.stdin.readline())
	people = list(map(int, sys.stdin.readline().split()))
	ans = 0
	people.sort(reverse=True)
	for i in range(1, n):
		ans += people[0] - people[i]
	print(ans)
main()


n = int(input())
arr = input()
l = list(map(int, arr.split(' ')))
l.sort()
c = 0
sum = 0
for c in range(n - 1):
	if l[c] < l[n - 1]:
		sum += l[n - 1] - l[c]
	c += 1
print(sum)


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


n = input()
l = input().split()
li = []
f = 0
for i in l:
	li.append(int(i))
m = max(li)
for x in li:
	if x < m:
		r = m - x
		f += r
print(f)


n = int(input())
burles = list(map(int, input().split()))[:n]
larger = max(burles, key=int)
result = 0
for burle in burles:
	result += larger - burle
print(result)


import sys
n = int(input())
arr = list(map(int, input().split()))
m = max(arr)
sum = 0
for i in range(n):
	sum += m - arr[i]
print(sum)


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


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


n = input()
lst = list(map(int, input().split()))
m = max(lst)
total = 0
for e in lst:
	total += m - e
print(total)


import sys
for s in sys.stdin:
	num = list(map(int, str(input()).split(' ')))
	tot = 0
	for i in range(0, len(num)):
		tot += max(num) - num[i]
	print(tot)


def read_input():
	a = []
	n = int(input())
	line = input().strip().split()
	for i in range(n):
		a.append(int(line[i]))
	return (n, a)

def calculate(n, a):
	a_max = a[0]
	a_sum = a_max
	for i in range(1, n):
		a_sum += a[i]
		if a_max < a[i]:
			a_max = a[i]
	return n * a_max - a_sum
(n, a) = read_input()
print(calculate(n, a))


n = int(input())
a = list(map(int, input().split()))
g = a[0]
for x in range(n):
	if g < a[x]:
		g = a[x]
z = 0
for x in a:
	z = z + (g - x)
print(z)


a = list(map(int, input().split()))
v = list(map(int, input().split()))
k = 0
tod = max(v)
for item in v:
	if item == tod:
		k += 0
	else:
		k += tod - item
print(k)


n = int(input())
a = [int(x) for x in input().split()]
b = max(a)
t = []
for i in a:
	c = b - i
	t.append(c)
d = sum(t)
print(d)


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


n = int(input())
tab = list(map(int, input().split()))
tab.sort()
burles = 0
for i in tab:
	burles += tab[-1] - i
print(burles)


import sys

def buckwheat(wealth_dist):
	richest = max(wealth_dist)
	min_buckwheat = sum([richest - p for p in wealth_dist])
	return min_buckwheat

def solution():
	first_line = sys.stdin.readline()
	second_line = sys.stdin.readline()
	population = int(first_line.strip())
	wealth_dist = list(map(int, second_line.split()))
	print(buckwheat(wealth_dist))
solution()


n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
print(l[n - 1] * n - sum(l))


n = int(input())
citizen = list(map(int, input().split()))
welfare = max(citizen)
give = 0
for i in range(n):
	give += welfare - citizen[i]
print(give)


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


n = int(input())
money = list(map(int, input().split()))
maxim = max(money)
count = 0
for i in range(len(money)):
	if money[i] != maxim:
		count += maxim - money[i]
print(count)


n = int(input())
l = list(map(int, input().split()))
if n == 1:
	print(0)
else:
	m = max(l)
	s = 0
	for i in range(n):
		s = s + (m - l[i])
	print(s)


n = int(input())
a = list(map(int, input().split()))
maxi = max(a)
sum = 0
for val in a:
	sum += maxi - val
print(sum)


n = int(input())
li = [int(x) for x in input().split()]
li.sort()
max = max(li)
total = 0
for i in li:
	total = total + (max - i)
print(total)


n = int(input())
welfare = list(map(int, input().split()))
maxWelfare = welfare[0]
for i in range(1, n):
	maxWelfare = max(welfare[i], maxWelfare)
burlesNeeded = 0
for i in range(0, n):
	burlesNeeded += maxWelfare - welfare[i]
print(burlesNeeded)


number_of_citizens = int(input())
welfare_acquired = [int(x) for x in input().split(' ')]
if number_of_citizens == 1:
	print('0')
elif welfare_acquired.count(welfare_acquired[0]) == len(welfare_acquired):
	print('0')
else:
	welfare_required = 0
	highest_paid = max(welfare_acquired)
	for welfare in welfare_acquired:
		welfare_required += highest_paid - welfare
	print(welfare_required)


n = int(input())
s = input().split()
l = []
count = 0
for i in s:
	l.append(int(i))
big = max(l)
for j in l:
	count = count + (big - j)
print(count)


n = input()
a = list(map(int, input().split()))
print(sum(list(map(lambda w: abs(w - max(a)), a))))


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


a = int(input())
b = input().split()
c = []
basis = 0
for x in b:
	c.append(int(x))
basis = max(c) * a - sum(c)
print(basis)


a = int(input())
b = input().split()
m = []
for j in b:
	m.append(int(j))
m.sort(reverse=False)
c = 0
for i in range(0, a - 1):
	d = int(m[a - 1]) - int(m[i])
	c = c + d
print(c)


n = int(input())
x = 0
s = sorted(list(map(int, input().split())))
for i in s:
	if i < max(s):
		x += max(s) - i
print(x)


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


def read(type=int):
	return type(input())

def read_arr(type=int):
	return [type(token) for token in input().split()]
mod = 10 ** 9 + 7

def mod_sum(A):
	s = 0
	for a in A:
		s = (s + a) % mod
	return s

def show(DP):
	for row in DP:
		print(row)
	print()

def solution():
	pass

def run():
	n = read()
	A = read_arr()
	m = max(A)
	s = 0
	for a in A:
		s += m - a
	print(s)
run()


n = int(input())
a = [int(i) for i in input().split()]
a.sort()
m = a[n - 1]
cost = 0
for i in a:
	cost += abs(i - m)
print(cost)


input()
welfares = [int(i) for i in input().split()]
ans = len(welfares) * max(welfares) - sum(welfares)
print(ans)


n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
b = a[-1]
count = 0
for i in a:
	count += b - i
print(count)


n = int(input())
a = list(map(int, input().split(' ')))
mx = max(a)
out = 0
for e in a:
	out += mx - e
print(out)


n = int(input())
arr = [int(i) for i in input().split(' ')]
counter = 0
a = max(arr)
for i in arr:
	counter += a - i
print(counter)


x = int(input())
y = list(map(int, input().split()))
max = 0
r = 0
for q in range(x):
	if y[q] > max:
		max = y[q]
	r += y[q]
print(max * x - r)


n = int(input())
ls = list(map(int, input().split()))
mx = -1 * 1000000000.0
for i in ls:
	mx = max(mx, i)
ans = 0
for i in ls:
	ans += abs(mx - i)
print(ans)


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


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


from sys import stdin
inputs = []
for s in stdin:
	inputs.append([int(x) for x in s.split(' ')])
n = inputs[0][0]
welfare = inputs[1]
res = max(welfare) * n - sum(welfare)
print(res)


n = int(input())
l = list(map(int, input().strip().split()))
c = 0
if len(l) > 1:
	flag = max(l)
	for i in range(len(l)):
		if l[i] < flag:
			c += flag - l[i]
print(c)


n = int(input())
l = list(map(int, input().split()))
sum = 0
maximum = max(l)
for i in l:
	if i < maximum:
		sum += maximum - i
print(sum)


n = int(input())
welfare = tuple(map(int, input().split()))
maximum = max(welfare)
total_welfare_to_be_distributed = 0
if len(welfare) == 1:
	pass
else:
	for i in range(len(welfare)):
		total_welfare_to_be_distributed += maximum - welfare[i]
print(total_welfare_to_be_distributed)


n = int(input())
a = input().split()
count = 0
maximum = 0
s = 0
for i in range(len(a)):
	ai = int(a[i])
	if i == 0:
		maximum = ai
		count += 1
	elif ai > maximum:
		s += count * (ai - maximum)
		maximum = ai
		count += 1
	else:
		s += maximum - ai
		count += 1
print(s)


n = int(input())
lst = [int(i) for i in input().split()]
max = max(lst)
sum = 0
for i in lst:
	sum = sum + max - i
print(sum)


n = input()
l = input().split()
j = 0
while j < len(l):
	l[j] = int(str(l[j]))
	j = j + 1
i = 0
max1 = 0
while i < len(l):
	if max1 < l[i]:
		max1 = l[i]
	i = i + 1
charges = 0
i = 0
while i < len(l):
	if l[i] < max1:
		charges += max1 - l[i]
	i = i + 1
print(charges)


import math
import sys
import heapq
from collections import deque, defaultdict
from itertools import permutations, combinations, combinations_with_replacement
import random
import os
mod = 10 ** 9 + 7
MAX = sys.maxsize
MIN = -sys.maxsize - 1

def isPrime(n):
	if n > 1:
		for i in range(2, n):
			if n % i == 0:
				return False
		else:
			return True
	else:
		return False

def isPanagram(s):
	alphabet = 'abcdefghijklmnopqrstuvwxyz'
	for char in alphabet:
		if char not in s.lower():
			return False
	return True

def isEqual(list1):
	if len(list1) < 0:
		res = True
	res = all((ele == list1[0] for ele in list1))
	if res:
		return True
	else:
		return False

def remove_duplicate(list1):
	final_list = []
	for i in list1:
		if i not in final_list:
			final_lis.append(i)
	return final_list

def solve():
	n = list(map(int, input().split()))
	n.sort()
	s = 0
	for i in range(len(n)):
		s += n[i]
	return len(n) * n[len(n) - 1] - s
t = int(input())
print(solve())


n = int(input())
b = list(map(int, input().split()))
m = 0
for x in range(0, n):
	m = max(m, b[x])
res = 0
for x in range(0, n):
	res = res + (m - b[x])
print(res)


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


xx = int(input())
welfare = [int(x) for x in input().split()]
mex = welfare[0]
for i in range(1, xx):
	mex = max(welfare[i], mex)
burl = 0
for j in range(0, xx):
	burl += mex - welfare[j]
print(burl)


n = int(input())
total = 0
a = [int(x) for x in input().split()]
b = max(a)
for i in a:
	total += b - i
print(total)


n = int(input())
a = list(map(int, input().split()))
count = 0
i = 0
while i < n:
	count += max(a) - a[i]
	i += 1
print(count)


n = int(input())
welfare = list(map(int, input().split()))
x = max(welfare)
burles = 0
for i in welfare:
	if i == x:
		continue
	else:
		burles += x - i
print(burles)


n = int(input())
A = list(map(int, input().split()))
Max = max(A)
Ans = 0
for val in A:
	Ans += abs(Max - val)
print(Ans)


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


n = int(input())
welfare = [int(x) for x in input().split()]
(sums, maximum) = (0, 0)
for i in welfare:
	sums += i
	maximum = max(maximum, i)
print(int(n * maximum - sums))


n = int(input())
a = list(map(int, input().split()))
maximal = max(a)
sum = 0
for i in range(n):
	if a[i] != maximal:
		sum = sum + (maximal - a[i])
	else:
		sum = sum + 0
print(sum)


n = int(input())
sums = 0
arr = [0] * n
arr = list(map(int, input().split()))
arr.sort()
maxs = arr[n - 1]
for i in range(0, n - 1):
	sums += abs(maxs - arr[i])
print(sums)


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


import math

def main():
	N = int(input())
	arr = [int(i) for i in input().split()]
	m = max(arr)
	ans = 0
	for i in range(N):
		ans += abs(arr[i] - m)
	print(ans)
main()


t = int(input())
l = list(map(int, input().split()))
a = max(l)
c = 0
for i in range(len(l)):
	if l[i] < a:
		c = c + a - l[i]
print(c)


a = int(input())
b = list(map(int, input().split()))
b.sort()
b.reverse()
u = 0
for i in range(1, len(b)):
	u = u + b[0] - b[i]
print(u)


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


def main():
	n = int(input())
	a = [int(i) for i in input().split(' ')]
	r = max(a)
	print(sum([r - i for i in a]))
main()


n = int(input())
li = list(map(int, input().split()))
c = 0
for i in range(len(li)):
	c += max(li) - li[i]
print(c)


n = int(input())
l = input()
lst = map(int, l.split())
lst = list(lst)
maxi = max(lst)
ans = 0
for i in lst:
	if i < maxi:
		v = maxi - i
		ans += v
print(ans)


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


_ = input()
coins = list(map(int, input().split()))
richest = max(coins)
print(sum(map(lambda x: richest - x, coins)))


a = int(input())
A = []
m = n = 0
A = input().split()
for i in range(a):
	n += int(A[i])
	if m < int(A[i]):
		m = int(A[i])
c = a * m - n
print(c)


n = int(input())
x = list(map(int, input().split()[:n]))
mx = max(x)
toadd = 0
for i in x:
	if i != mx:
		toadd += mx - i
	else:
		pass
print(toadd)


x = input()
list1 = list(map(int, input().split()))
finalval = 0
val = max(list1)
for i in list1:
	finalval += val - i
print(finalval)


citizens = int(input())
welfares = list(map(int, input().split()))
max_welfare = max(welfares)
sum_welfare = sum(welfares)
necessary_welfare = max_welfare * citizens - sum_welfare
print(necessary_welfare)


n = int(input())
a = list(map(int, input().split()))
max_money = max(a)
count = 0
for i in range(len(a)):
	if a[i] < max_money:
		count = count + (max_money - a[i])
print(count)


n = int(input())
welfare = [int(i) for i in input().split(' ')]
welfare.sort()
spent_burles = 0
max_burles = welfare[n - 1]
for i in range(0, n - 1):
	spent_burles += max_burles - welfare[i]
print(spent_burles)


n = int(input())
arr = list(map(int, input().split()))
l = list(arr)
res = 0
for i in range(len(l)):
	res += max(l) - l[i]
print(res)


from functools import reduce
c = int(input())
n = input()
people = [int(i) for i in n.split()]

def maxi(x, y):
	if x > y:
		return x
	else:
		return y

def sumy(x, y):
	return x + y

def conctaEqual(o):
	p = reduce(maxi, people)
	return p - o
print(reduce(sumy, list(map(conctaEqual, people))))


n = int(input())
arr = list(map(int, input().split()))
maxi = max(arr)
count = 0
for i in range(n):
	if arr[i] != maxi:
		count += maxi - arr[i]
print(count)


import sys
n = int(sys.stdin.readline())
welfares = [int(c) for c in sys.stdin.readline().split()]
needed = max(welfares) * n
curr = sum(welfares)
print(str(needed - curr))


n = int(input())
l = input().split(' ')
for i in range(len(l)):
	l[i] = int(l[i])
m = max(l)
c = 0
for i in l:
	c = c + m - i
print(c)


def equality(arr):
	big = max(arr)
	ans = 0
	for i in arr:
		ans += big - i
	return ans
n = int(input())
x = list(map(int, input().rstrip().split()))
print(equality(x))


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


n = input()
wel = list(map(int, input().split()))
mx = max(wel)
g = 0
for i in wel:
	g = g + mx - i
print(g)


n = int(input())
citizins = list(map(int, input().split()))
count = 0
total = 0
max_welfare = max(citizins)
for i in citizins:
	if i < max_welfare:
		count += 1
		total += max_welfare - i
print(0 if count == 0 else total)


n = int(input())
l_a = list(map(int, input().split(' ')))
m_a = max(l_a)
ans = 0
for i in l_a:
	if i < m_a:
		ans += m_a - i
print(ans)


a = int(input())
b = input().split()
for i in range(len(b)):
	b[i] = int(b[i])
c = int(0)
d = int(max(b))
for j in range(len(b)):
	c += int(d - int(b[j]))
print(int(c))


n = int(input())
a = list(map(int, input().split()))
k = max(a)
a.remove(k)
answer = 0
for i in range(n - 1):
	if a[i] != k:
		answer += k - a[i]
print(answer)


n = int(input())
a = list(map(int, input().split()))
money = 0
if len(a) > 1:
	max_money = a.pop(a.index(max(a)))
	for i in a:
		money += max_money - i
print(money)


n = int(input())
moneys = [int(x) for x in input().split()]
moneys.sort(reverse=True)
total = 0
for money in moneys:
	total += money
print(len(moneys) * moneys[0] - total)


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


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


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


n = int(input())
arr = list(map(int, input().split()))
(maxi, tot) = (max(arr), 0)
for i in range(n):
	tot += maxi - arr[i]
print(tot)


n = int(input())
a = [int(_) for _ in input().split()]
ans = max(a)
ans = ans * n - sum(a)
print(ans)


number = int(input())
alist = list(map(int, input().split()))
alist.sort()
money = 0
for i in alist[:number - 1]:
	money += alist[-1] - i
print(money)


money = 0
n = int(input())
membersWelfare = list(map(int, input().split(' ')))
highestWelfare = max(membersWelfare)
for i in range(n):
	money += highestWelfare - membersWelfare[i]
print(money)


n = int(input())
a = [int(x) for x in input().split()]
a.sort(reverse=True)
max_wealth = a[0]
print(n * max_wealth - sum(a))


n = int(input())
burls = list(map(int, input().split()))
burls_count = []
k = max(burls)
for i in range(n):
	a = k - burls[i]
	burls_count.append(a)
print(sum(burls_count))


x = int(input())
y = list(map(int, input().split()))
sum = 0
y.sort()
i = 0
while i < len(y) - y.count(max(y)):
	sum += max(y) - y[i]
	i += 1
print(sum)


n = int(input())
li = list(map(int, input().split()))
ma = max(li)
su = 0
for i in li:
	su += ma - i
print(su)


def run(money_array):
	max = 0
	for count in money_array:
		if max < count:
			max = count
	res = 0
	for count in money_array:
		res += max - count
	return res

def run_input():
	inp = str(input())
	inp2 = str(input()).split()
	res = []
	for i in inp2:
		res.append(int(i))
	print(run(res))
	return
run_input()


input()
l = list(map(int, input().split()))
print(sum((max(l) - i for i in l)))


n = int(input())
str = input()
arr = str.split()
max = 0
for i in range(n):
	if int(arr[i]) > max:
		max = int(arr[i])
sum = 0
for i in range(n):
	sum = sum + (max - int(arr[i]))
print(sum)


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


input()
n = list(map(int, input().split()))
m = max(n)
print(sum(map(lambda i: m - i, n)))


n = int(input())
A = input()
B = []
for i in A.split():
	B.append(int(i))
Max = max(B)
Sum = sum(B)
print(Max * n - Sum)


n = int(input())
welfare = list(map(int, input().strip().split(' ')))[:n]
maxWel = welfare[0]
for i in range(1, n):
	maxWel = max(welfare[i], maxWel)
burles = 0
for i in range(n):
	burles += maxWel - welfare[i]
print(burles)


cits = int(input())
wel = list(map(int, input().split()))
maxim = max(wel)
giv = 0
for i in wel:
	giv += maxim - i
print(giv)


n = int(input())
s = list(map(int, input().split()))
ma = max(s)
need = 0
for i in s:
	if i < ma:
		need += ma - i
print(need)


n = int(input())
current_welfare = [int(x) for x in input().split(' ')]
standard_welfare = max(current_welfare)
count = 0
for item in current_welfare:
	a = standard_welfare - item
	count += a
print(count)


n = int(input())
a = [int(i) for i in input().split()]
m = max(a)
S = 0
for i in range(n):
	S += m - a[i]
print(S)


a = int(input())
b = list(map(int, input().split()))
b = sorted(b)
c = sum(b)
d = a * max(b)
print(d - c)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, random
n = int(input())
w = list(map(int, input().split()))
minW = max(w)
ans = 0
for i in range(n):
	ans += abs(w[i] - minW)
print(ans)


import math
from collections import Counter

def get(f):
	return map(f, input().split())

def divides(a, b):
	return a % b == 0

def main():
	n = int(input())
	a = sorted(get(int))
	ans = 0
	for i in range(n - 1):
		ans += a[-1] - a[i]
	print(ans)
main()


n = int(input())
l = [*map(int, input().split())]
print(sum((max(l) - i for i in l)))


def main():
	n = int(input())
	list1 = list(map(int, input().split(' ')))
	sum1 = sum(list1)
	c = max(list1)
	print(n * c - sum1)
main()


n = int(input())
arr = list(map(int, input().split()))
s = []
m = max(arr)
for i in arr:
	s.append(abs(m - i))
print(sum(s))


n = int(input(''))
c = list(map(int, input().split()[:n]))
c.sort()
s = 0
for i in range(n):
	k = c[n - 1] - c[i]
	s = s + k
print(s)


n = int(input())
a = [int(x) for x in input().split()]
max = a[0]
for i in range(1, n):
	if a[i] > max:
		max = a[i]
sum = 0
for i in range(0, n):
	sum = sum + (max - a[i])
print(sum)


input()
welfares = list(map(int, input().split()))
x = 0
max = max(welfares)
for w in welfares:
	x += max - w
print(x)


n = eval(input())
temp = input()
temp = temp.split()
for i in range(len(temp)):
	temp[i] = int(temp[i])
maxi = max(temp)
count = 0
for i in temp:
	count += maxi - i
print(count)


q = 0
r = 0
a = int(input())
b = input().split()
for u in range(len(b)):
	if r < int(b[u]):
		r = int(b[u])
r = int(r)
for i in range(a):
	q = q + r - int(b[i])
print(q)


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


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


x = int(input())
a = list(map(int, input().split()))
t = max(a)
c = 0
for i in a:
	if i < t:
		e = t - i
		c += e
print(c)


n = int(input())
a = list(map(int, input().split()))
b = max(a)
S = 0
for i in range(len(a)):
	if len(a) == 1:
		S == 0
		break
	elif a[i] != b:
		S = S + (b - a[i])
print(S)


ctzns = int(input().strip(' '))
burles = list(map(int, input().strip(' ').split(' ')))
total = list(map(lambda x: max(burles) - x, burles))
print(sum(total))


def main():
	input()
	maxv = 0
	s = [int(x) for x in input().split(' ')]
	for i in s:
		maxv = max(i, maxv)
	count = 0
	for i in s:
		count += maxv - i
	print(count)
main()


n = int(input())
line = input()
money = line.split()
result = 0
for i in range(n):
	money[i] = int(money[i])
maximum = max(money)
for i in range(n):
	result += maximum - money[i]
print(result)


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


y = int(input())
s = input().split()
x = []
for i in s:
	x.append(int(i))
res = 0
for i in x:
	res += max(x) - i
print(res)


def max1(a):
	p = a[0]
	for x in a:
		if x > p:
			p = x
	return p
n = int(input())
a = list(map(int, input().split()))
q = 0
p = max1(a)
for x in a:
	q += p - x
print(q)


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


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


a = input()
m = list(map(int, input().strip().split()))
max1 = int(max(m))
list1 = []
for i in m:
	b = max1 - i
	list1.append(b)
print(sum(list1))


def function1():
	pass

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


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


s = int(input())
r = list(map(int, input().split()))
w = max(r)
if w == 0:
	print(0)
else:
	count = 0
	for i in r:
		count += w - i
	print(count)


n = int(input())
l = list(map(int, input().split()))
M = max(l)
res = 0
for i in l:
	res = res + (M - i)
print(res)


n = int(input())
wealth = [int(i) for i in input().split()]
Bwealth = max(wealth)
sum = 0
for i in wealth:
	sum += Bwealth - i
print(sum)


n = int(input())
z = str(input()).split()
arr = []
for i in range(n):
	arr.append(int(z[i]))
nilai = max(arr)
count = 0
for i in range(n):
	count += nilai - arr[i]
print(count)


import math
import os
import random
import re
import sys
total = 0
input()
a = [int(x) for x in input().split()]
most = max(a)
for i in a:
	if i < most:
		total = total + (most - i)
print(total)


n = int(input())
list1 = list(map(int, input().split()))
list1.sort()
x = int(0)
for i in range(n):
	x = x + (list1[-1] - list1[i])
print(x)


input()
money = [int(x) for x in input().split()]
print(sum((max(money) - m for m in money)))


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


inp = int(input())
other = input()
other = other.split()
other = [int(ot) for ot in other]
big = max(other)
total = 0
for i in other:
	total += big - int(i)
print(total)


n = int(input())
a = list(map(int, input().split(' ')))
diff = list(map(lambda x: max(a) - x, a))
print(sum(diff))


n = input()
arr = [int(i) for i in input().split()]
arr.sort()
sum = 0
max = arr[len(arr) - 1]
for i in arr:
	sum += max - i
print(sum)


d = 0
m = 0
x = int(input())
z = input().split()
for i in range(x):
	if int(z[i]) > m:
		m = int(z[i])
z.remove(str(m))
for k in range(len(z)):
	d += m - int(z[k])
print(d)


def HoliEqual(l):
	m = 0
	resul = 0
	m = max(l)
	result = sum((m - x for x in l))
	print(int(result))
t = input()
t = input()
h = [int(x) for x in t.split()]
HoliEqual(h)


a = int(input())
s = input().split()
m = int(s[0])
for i in range(a):
	if m < int(s[i]):
		m = int(s[i])
c = 0
for i in range(a):
	c += m - int(s[i])
print(c)


n = int(input())
s = input().split()
for i in range(n):
	s[i] = int(s[i])
s.sort(reverse=True)
b = 0
for i in range(1, n):
	b = b + (s[0] - s[i])
print(b)


n = int(input())
arr = []
arr.append(input().split())
arr2 = []
for i in arr[0]:
	arr2.append(int(i))
max1 = max(arr2)
count = 0
for i in range(len(arr2)):
	if arr2[i] != max1:
		count += max1 - arr2[i]
print(count)


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


n = int(input())
arr = [int(elem) for elem in input().split()]
(max_arr, summ) = (max(arr), 0)
for i in range(n):
	summ += max_arr - arr[i]
print(summ)


b = int(input())
l = list(map(int, input().split(' ')))
a = max(l)
s = 0
for k in l:
	s += a - k
print(s)


import sys

def main():
	ppl = int(sys.stdin.readline().strip())
	if ppl == 1:
		print(0)
		return
	welfare = [int(x) for x in sys.stdin.readline().strip().split()]
	highest = max(welfare)
	charges = 0
	for x in welfare:
		charges += highest - x
	print(charges)
main()


a = int(input())
s = [int(x) for x in input().split()]
c = max(s)
ans = 0
for i in s:
	ans += c - i
print(ans)


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


n = int(input())
a = sorted(map(int, input().split()))
print(n * a[-1] - sum(a))


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


input()
incomes = [int(x) for x in input().split()]
max_incomes = max(incomes)
adds = sum((max_incomes - x for x in incomes))
print(adds)


_ = input()
w = list(map(int, input().split()))
m = max(w)
cost = 0
for a in w:
	cost += m - a
print(cost)


input()
lst = [int(k) for k in input().split(' ')]
mx = max(lst)
print(sum([mx - k for k in lst]))


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


t = int(input())
li = list(map(int, input().split()))
li.sort()
m = li[t - 1]
s = 0
for i in li:
	if i < m:
		s += m - i
print(s)


n = int(input())
a_nums = list(map(int, input().split()))
a_max = max(a_nums)
ans = 0
if n == 1:
	print(0)
else:
	for a in a_nums:
		ans += a_max - a
	print(ans)


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


number_of_citizens = int(input())
wealth = input().split()
smallest = []
largest = 0
for x in wealth:
	if int(x) >= largest:
		largest = int(x)
for x in wealth:
	if int(x) < largest:
		smallest.append(int(x))
total = 0
for x in smallest:
	if int(x) < largest:
		total += int(largest) - int(x)
print(total)


n = int(input())
lst = input().split()
for i in range(n):
	lst[i] = int(lst[i])
count = 0
diff = max(lst)
for i in lst:
	count = count + (diff - i)
print(count)


input()
(a, *b) = sorted(map(int, input().split()), reverse=True)
print(sum((a - x for x in b)))


n = int(input())
n1 = list(map(int, input().split()[:n]))
sum = 0
s = max(n1)
n1.remove(s)
for i in n1:
	k = s - i
	sum += k
print(sum)


n = int(input())
a = list(map(int, input().split()))
ans = 0
if n == 1:
	print('0')
else:
	a.sort(reverse=True)
	t = a[0]
	for i in range(1, len(a)):
		ans += t - a[i]
	print(ans)


n = int(input())
a = [int(x) for x in input().split()]
mx = max(a)
ans = 0
for i in range(n):
	if a[i] != mx:
		ans += mx - a[i]
print(ans)


t = int(input())
a = []
s = sorted(list(map(int, input().split())))
l = len(s) - 1
for i in range(len(s)):
	a.append(s[l] - s[i])
s = 0
for i in a:
	s = s + int(i)
print(s)


from functools import reduce
n = int(input())
p = input()
ppl = [int(x) for x in p.split()]

def higher(x, y):
	return x if x > y else y

def sum(x, y):
	return x + y

def equalize(x):
	hi = reduce(higher, ppl)
	return hi - x
print(reduce(sum, list(map(equalize, ppl))))


def BubbleSort(alist):
	for i in range(len(alist) - 1, 0, -1):
		flag = 0
		for k in range(i):
			if alist[k] > alist[k + 1]:
				(alist[k], alist[k + 1]) = (alist[k + 1], alist[k])
				flag = 1
		if flag == 0:
			break
	return alist
input()
a = [int(x) for x in input().split()]
a = BubbleSort(a)
res = 0
for i in range(0, len(a) - 1):
	res += a[-1] - a[i]
print(res)


n = int(input())
welfare = [int(x) for x in input().split()]
maxum = max(welfare)
expence = 0
for i in welfare:
	expence += maxum - i
print(expence)


n = int(input())
l = list(map(int, input().split(' ')))
l = sorted(l)
a = l[-1]
l.remove(l[-1])
if n == 1:
	print('0')
else:
	sum = 0
	for i in l:
		sum += a - i
	print(sum)


def Holiday(n, s):
	res = 0
	max1 = max(s)
	for i in range(n):
		res = res + (max1 - s[i])
	return res
x = int(input())
res = [int(n) for n in input().split()]
print(Holiday(x, res))


n = int(input())
money = list(map(int, input().split()))
count = 0
limit = max(money)
for i in range(n):
	count += limit - money[i]
print(count)


n = int(input())
a = [int(x) for x in input().split()]
x = a.sort(reverse=True)
l = a[0]
count = 0
for b in a:
	count += l - b
print(count)


n = int(input())
welfare = list(map(int, input().split()))
count = 0
x = max(welfare)
welfare.sort()
welfare.pop()
for i in range(n - 1):
	count += x - welfare[i]
print(count)


n = int(input())
a = list(map(int, input().split()))
a.sort()
m = max(a)
k = 0
for i in range(len(a)):
	if m - a[i] != 0:
		k += m - a[i]
	else:
		break
print(k)


LIMIT = int(input())
nums = map(int, input().split())
nums = sorted(nums)
total = 0
for i in range(LIMIT):
	total += abs(max(nums) - nums[i])
print(total)


l = int(input())
money = input()
money = money.split()
for (index, item) in enumerate(money):
	money[index] = int(item)
critical = max(money)
s = 0
for item in money:
	s += critical - item
print(s)


N = int(input())
a = [int(x) for x in input().split()]
m = max(a)
s = 0
for x in range(N):
	s = s + (m - a[x])
print(s)


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


from sys import stdin, stdout
people = int(stdin.readline())
moneys = list(map(int, stdin.readline().split()))
maximum = max(moneys)
expences = 0
for money in moneys:
	expences += maximum - money
stdout.write(str(expences) + '\n')


input()
d = [int(x) for x in input().split()]
maxa = max(d)
d.remove(maxa)
print(abs(sum(d) - maxa * len(d)))


numb = int(input())
word = str(input())
word = word.split(' ')
for n in range(numb):
	word[n] = int(word[n])
money = 0
eqa = max(word)
for n in range(numb):
	money = money + (eqa - word[n])
print(money)


n = int(input())
wealth = list(map(int, input().split()))
if n == 1:
	print(0)
else:
	max_ = max(wealth)
	give = [max_ - w for w in wealth]
	print(sum(give))


t = int(input())
a = [int(a) for a in input().split()]
p = max(a)
(c, f) = (0, 0)
d = []
while c < len(a):
	d.append(p - a[c])
	c = c + 1
for i in d:
	f = f + i
print(f)
(c, f) = (0, 0)
a.clear()
d.clear()


import functools
cnt = int(input())
arr = list(map(int, input().split()))
maxi = max(arr)
print(functools.reduce(lambda r, c: r + maxi - c, arr, 0))


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


def coints_count(people_coints):
	richer_coints = max(people_coints)
	coints = 0
	for person_coints in people_coints:
		coints += richer_coints - person_coints
	return coints

def main():
	_ = input()
	people_coints = list(map(int, input().split()))
	print(coints_count(people_coints))
main()


n = input()
arr = [int(i) for i in input().split(' ')]
(maxi, res) = (max(arr), 0)
for i in arr:
	res += maxi - i
print(res)


a = int(input())
lst = [int(i) for i in input().split()]
lst.sort()
s = 0
for j in lst:
	s += j
s -= lst[-1]
print(lst[-1] * (a - 1) - s)


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


n = int(input())
s = list(map(int, input().split()))
max_s = max(s)
print(sum((max_s - i for i in s)))


n = input()
welfare = list(map(int, input().strip().split()))
sub = max(welfare)
sum = 0
for i in welfare:
	sum += sub - i
print(sum)


n = int(input())
d = list(map(int, input().split()))
m = max(d)
S = 0
for i in range(n):
	if d[i] < m:
		a = m - d[i]
		S += a
print(S)


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


n = int(input())
mon = list(map(int, input().split()))
loan = 0
plan = max(mon)
for i in range(len(mon)):
	loan += plan - mon[i]
print(loan)


_ = int(input())
main = list(map(int, input().split()))
maxx = max(main)
ans = 0
for k in main:
	ans += maxx - k
print(ans)


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


n = int(input())
num = list(map(int, input().split(' ')))
maximum = max(num)
count = 0
for i in range(n):
	if num[i] == maximum:
		count = count + 0
		continue
	else:
		value = maximum - num[i]
		sum = num[i] + value
		count = count + value
print(count)


n = int(input())
welfare = [int(i) for i in input().split(' ')]
m = max(welfare)
cnt = 0
for i in welfare:
	cnt += m - i
print(cnt)


n = int(input())
l = list(map(int, input().split()))
maxx = max(l)
c = 0
for i in range(len(l)):
	t = maxx - l[i]
	c += t
print(c)


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


n = int(input())
l = list(map(int, input().split()))
c = max(l)
l.remove(c)
print(c * (n - 1) - sum(l))


NC = int(input())
WOC = input().split()
x = 0
for a in WOC:
	WOC[x] = int(a)
	x += 1
maxi = 0
for a in WOC:
	maxi = max(WOC)
count = 0
for a in WOC:
	if maxi > a:
		count += maxi - a
print(count)


try:
	n = int(input())
	if n < 1 or n > 100:
		raise ValueError
	a = input()
	b = a.split(' ')
	if len(b) != n:
		raise ValueError
	for i in range(len(b)):
		if int(b[i]) < 0 or int(b[i]) > 10 ** 6:
			raise ValueError
except ValueError:
	print('Wrong string')
else:
	count = 0
	max = 0
	for i in range(len(b)):
		if int(b[i]) > max:
			max = int(b[i])
	for i in range(len(b)):
		count = count + (max - int(b[i]))
	print(count)


num = int(input())
arr = list(map(int, input().split()))
arr.sort(reverse=True)
count = 0
for i in range(1, num):
	count += arr[0] - arr[i]
print(count)


n = int(input())
lst = list(map(int, input().split()))
Max = max(lst)
Ans = 0
for i in range(n):
	Ans += Max - lst[i]
print(Ans)


n = int(input())
welfare = list(map(int, input().split()))
equal = max(welfare)
spend = sum((equal - w for w in welfare))
print(spend)


n = int(input())
num = input()
list = [int(x) for x in num.split()]
a = max(list)
w = 0
for i in list:
	w += a - i
print(w)


k = int(input())
a = list(map(int, input().split()))
a.sort()
b = max(a)
c = 0
for i in range(len(a) - 1):
	c += b - a[i]
print(c)


list_2 = []
num = int(input())
list_1 = list(map(int, input().split()))
list_1.sort()
end_cifra = list_1[-1]
for cifra in list_1:
	if cifra < end_cifra:
		list_2.append(end_cifra - cifra)
summa = sum(list_2)
print(summa)


n = int(input())
burles = [int(s) for s in input().split()]
count = 0
Max = max(burles)
for i in range(len(burles)):
	if burles[i] < Max:
		count += Max - burles[i]
		burles[i] += Max - burles[i]
print(count)


num = int(input())
list1 = list(map(int, input().split()))
maxim = max(list1)
count = 0
for i in list1:
	if i <= maxim:
		count = count + (maxim - i)
print(count)


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


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


k = int(input())
arr = list(map(int, input().split()))
print(k * max(arr) - sum(arr))


citizens = []
burrels = 0
n = int(input())
citizens = list((int(num) for num in input().strip().split()))[:n]
max_list = max(citizens)
to_be_added = 0
for citi in citizens:
	to_be_added = to_be_added + (max_list - citi)
print(to_be_added)


def find(A):
	K = max(A)
	ans = K * len(A) - sum(A)
	return ans
N = input()
A = list(map(int, input().strip().split(' ')))
print(find(A))


from sys import exit as sys_ret
amount = int(input())
citizens = [int(_) for _ in input().split()]
maximal = -1
for i in citizens:
	maximal = max(maximal, i)
payment = 0
for i in citizens:
	payment += maximal - i
print(payment)


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


n = input()
z = list(map(int, input().split()))
p = max(z)
k = 0
for i in z:
	k = k + p - i
print(k)


n = int(input())
l = [int(x) for x in input().split()]
m = max(l)
c = 0
l.sort()
for i in range(n):
	if l[i] != m:
		c += m - l[i]
print(c)


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


p = int(input())
m = list(map(int, input().split()))
mx = 0
o = 0
for i in m:
	if i > mx:
		mx = i
for x in m:
	o += mx - x
print(o)


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


n = int(input())
l = list(map(int, input().strip().split()))
m = max(l)
t = 0
for i in l:
	if i == m:
		pass
	else:
		t += m - i
print(t)


n = int(input())
l = list(map(int, input().split()))
total = max(l)
burle = 0
for i in range(len(l)):
	burle = burle + total - l[i]
print(burle)


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


def holidayofequal():
	num_citi = int(input(''))
	welfare_list = []
	max_welfare = -1
	for num in input('').split():
		num = int(num)
		welfare_list.append(num)
		max_welfare = max(num, max_welfare)
	res = 0
	for welfare in welfare_list:
		res += max_welfare - welfare
	print(res)
holidayofequal()


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


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


n = int(input())
lis = [int(i) for i in input().split()]
if len(lis) == 1:
	print(0)
else:
	print(max(lis) * len(lis) - sum(lis))


n = int(input())
a = sorted(list(map(int, input().split()[:n])), reverse=True)
print(a[0] * n - sum(a))


import time

def calculateEqualWelfare(balances):
	richestCiti = max(balances)
	totalIncr = 0
	for bal in balances:
		totalIncr += richestCiti - bal
	return totalIncr

def solve():
	citizens = int(input())
	balancesCiti = list(map(int, input().split()))
	print(calculateEqualWelfare(balancesCiti))
solve()


def maintainEquality(burles):
	return sum([max(burles) - i for i in burles])
n = int(input())
burles = list(map(int, input().split(' ')))
print(maintainEquality(burles))


n = int(input())
mak = 0
pak = 0
for i in input().split():
	if int(i) > mak:
		mak = int(i)
	pak += int(i)
print(mak * n - pak)


n = int(input())
A = list(map(int, input().split()))
c1 = 0
c = 0
for i in range(0, len(A)):
	if A[i] < max(A):
		c1 += A[i]
		c += 1
print(max(A) * c - c1)


(_, citizen_wealths) = (input(), list(map(int, input().split())))
richest = max(citizen_wealths)
print(sum((richest - wealth for wealth in citizen_wealths)))


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


num = int(input())
arr = [0] * num
arr = input().split()
for p in range(num):
	arr[p] = int(arr[p])
arr.sort()
maxi = arr[num - 1]
total = 0
for j in range(num):
	total = total + (maxi - arr[j])
print(total)


number = int(input())
citizens = list(map(int, input().split()))
gift = 0
most_wealthy = max(citizens)
for x in citizens:
	gift += most_wealthy - x
print(gift)


m = int(input())
lst = [int(i) for i in input().split()]
a = max(lst)
y = 0
for i in lst:
	if i != a:
		y = y + (a - i)
print(y)


input()
a = [int(i) for i in input().split()]
maximum = max(a)
print(sum((maximum - i for i in a)))


n = int(input())
l = list(map(int, input().split()))
m = max(l)
l.remove(m)
print(sum((m - i for i in l)))


(length, lst) = (int(input()), list(map(int, input().split())))
checking = max(lst)
print(sum([checking - i for i in lst]))


n = int(input())
listt = [int(i) for i in input().split()]
listt.sort()
max = listt[n - 1]
ans = 0
for i in listt:
	if i == max:
		break
	ans += max - i
print(ans)


n = int(input().strip())
arr = [int(arr_temp) for arr_temp in input().strip().split(' ')]
sum = 0
for x in arr:
	sum += 0 + (max(arr) - x)
print(sum)


from sys import stdin, stdout
n = int(stdin.readline().strip())
ls = list(map(int, stdin.readline().strip().split()))
m = max(ls)
n = m * n
stdout.write('%d\n' % (n - sum(ls)))


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


import sys
n = int(input())
A = [int(a) for a in input().split()]
ans = 0
a_max = max(A)
for a in A:
	ans += a_max - a
print(ans)


n = int(input())
s = input().split()
my_list = []
count = 0
for i in s:
	my_list.append(int(i))
c = max(my_list)
for v in my_list:
	count += c - v
print(count)


res = 0
n = int(input())
a = [int(i) for i in input().split()]
ma = max(a)
for i in range(len(a)):
	res += ma - a[i]
print(res)


n = int(input())
wf = sorted(map(int, input().split()))
(maxx, wf) = (wf[-1], wf[:-1])
ans = 0
for i in wf:
	ans += maxx - i
print(ans)


import os

def changeStdioToFile():
	import sys
	path = os.path.dirname(os.path.abspath(__file__))
	sys.stdin = open(f'{path}/input.txt', 'r')
	sys.stdout = open(f'{path}/output.txt', 'w')
t = 1
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	res = 0
	for item in a:
		res += max(a) - item
	print(res)


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


n = int(input())
a = list(map(int, input().split()))
m = max(a)
res = 0
if n == 1:
	res = 0
else:
	for c in a:
		if c < m:
			res += m - c
print(res)


_ = input()
l_w = list(map(int, input().split()))
m = max(l_w)
t = 0
for w in l_w:
	t += m - w
print(t)


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


a = int(input())
b = input().split()
for i in range(len(b)):
	b[i] = int(b[i])
k = 0
d = int(max(b))
for i in range(len(b)):
	if b[i] < d:
		k = k + (d - b[i])
print(k)


input()
arr = list(map(int, input().split()))
(maxX, summ) = (0, 0)
for x in arr:
	if x > maxX:
		maxX = x
for x in arr:
	summ = summ + (maxX - x)
print(summ)


n = int(input())
ppl = [int(s) for s in input().split()]
goal = max(ppl)
burles = 0
for i in range(n):
	burles += goal - ppl[i]
print(burles)


n = int(input())
l = list(map(int, input().split()))
p = max(l)
sum1 = 0
for i in l:
	sum1 = sum1 + (p - i)
print(sum1)


q = int(input())
not_equality = list(map(int, input().split()))
burjui = max(not_equality)
difference = 0
for man in not_equality:
	difference += burjui - man
print(difference)


l = int(input())
a = list(map(int, input().split()))
c = 0
a.sort()
for i in range(l):
	if a[i] < a[-1]:
		c += a[-1] - a[i]
print(c, end='')


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


c = int(input())
w = input()
w = w.split()
w[0] = int(w[0])
x = w[0]
for i in range(1, c):
	w[i] = int(w[i])
	if w[i] > x:
		x = w[i]
t = 0
for i in range(c):
	t += x - w[i]
print(t)


n = int(input())
data = sorted([int(x) for x in input().split()])
print(data[n - 1] * n - sum(data))


def ms(v):
	(s, m) = (0, 0)
	for x in v:
		if m < x:
			m = x
		s += x
	return (m, s)

def kg(n, v):
	(m, s) = ms(v)
	return n * m - s
n = int(input())
v = [int(x) for x in input().split()]
print(kg(n, v))


x = int(input())
y = input().split()
z = []
for c in y:
	z.append(int(c))
money = 0
z.sort()
z.reverse()
for c in z[1:]:
	money = money + (z[0] - c)
print(money)


n = int(input())
check = [int(x) for x in input().split()]
k = max(check)
count = 0
for i in range(n):
	z = k - check[i]
	count += z
print(count)


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


N = int(input())
list1 = []
result = 0
list1 = input().split(' ')
list1 = [int(i) for i in list1]
max_element = max(list1)
for i in list1:
	result = result + max_element - i
print(result)


n = int(input())
l = list(map(int, input().split()))
m = max(l)
q = 0
for i in range(len(l)):
	t = 0
	if l[i] < m:
		t = m - l[i]
		l[i] = l[i] + t
		q += t
print(q)


n = int(input())
listm = list(map(int, input().split()))
max1 = max(listm)
count = 0
neta = n * max1
for i in listm:
	count += i
final = neta - count
print(final)


from sys import stdin, exit
n = int(stdin.readline().rstrip())
citizens = list(map(int, stdin.readline().rstrip().split(' ')))
h = max(citizens)
t = 0
for cur in citizens:
	t += h - cur
print(t)


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


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


n = int(input())
arr = [int(i) for i in input().split()]
add = 0
mx = arr[0]
for i in range(1, n):
	if mx < arr[i]:
		add += i * (arr[i] - mx)
		mx = arr[i]
	else:
		add += mx - arr[i]
print(add)


n = int(input())
niz = list(map(int, input().split()))
m = max(niz)
summ = 0
for x in niz:
	summ += m - x
print(summ)


n = int(input())
x = list(map(int, input().split()))
x.sort()
money = 0
for i in range(len(x) - 1):
	if x[i] != x[len(x) - 1]:
		money += x[len(x) - 1] - x[i]
print(money)


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


n = int(input())
a = [int(n) for n in input().split()]
max = a[0]
money = 0
for i in range(n):
	if a[i] > max:
		max = a[i]
for i in range(n):
	money += max - a[i]
print(money)


n = int(input())
h = [int(X) for X in input().split()]
v = []
k = max(h)
for i in h:
	v.append(i - k)
print(abs(sum(v)))


x = int(input())
l = list(map(int, input().split()))
c = 0
m = max(l)
for i in range(len(l)):
	c = c + (m - l[i])
print(c)


n = int(input())
listNumbers = [int(x) for x in input().split()]
maximumValue = max(listNumbers)
count = 0
for i in range(0, n):
	count += maximumValue - listNumbers[i]
print(count)


if input() == '1':
	print(0)
else:
	a = [int(x) for x in input().split()]
	x = max(a)
	burles = 0
	for i in a:
		burles += x - i
	print(burles)


n = int(input())
a = [int(a) for a in input().split()]
s = sum(a)
m = max(a)
rest = m * n - s
print(rest)


k = input()
k = [int(x) for x in input().split(' ')]
S = 0
for i in k:
	if i != max(k):
		S += max(k) - i
print(str(S))


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


def main():
	n = int(input())
	a = list(map(int, input().split()))
	t = max(a)
	s = 0
	for i in a:
		s += t - i
	print(s)
main()


n = int(input())
m = list(map(int, input().split()))
l1 = max(m)
c = 0
sum1 = 0
for i in range(n):
	c = l1 - m[i]
	sum1 = sum1 + c
print(sum1)


def trial():
	num = int(input())
	citizens = list(map(int, input().split()))
	rich = max(citizens)
	counter = 0
	for i in citizens:
		counter += rich - i
	return print(counter)
trial()


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


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


n = int(input())
l = [int(i) for i in input().split()]
tot = n * max(l)
sum = sum(l)
print(tot - sum)


m = int(input())
nums = list(map(int, input().split()))
count = 0
k = max(nums)
for i in range(len(nums)):
	count = count + (k - nums[i])
print(count)


n = int(input())
text = input().split()
li = [int(i) for i in text]
mx = max(li)
count = 0
for i in li:
	count += mx - i
print(count)


def max(x, y):
	if x > y:
		return x
	else:
		return y
n = input()
b = input()
b = b.split(' ')
c = []
maxnum = 0
sum = 0
for i in range(len(b)):
	c.append(int(b[i]))
	maxnum = max(maxnum, c[i])
for i in range(len(b)):
	sum += maxnum - c[i]
print(sum)


def find_max(l):
	my_max = l[0]
	for x in l:
		if x > my_max:
			my_max = x
	return my_max
n = int(input())
l = list(map(int, input().split(' ')))
maxim = find_max(l)
s = 0
for x in l:
	s += maxim - x
print(s)


input()
k = list(map(int, input().split()))
if len(k) == 1:
	print(0)
else:
	summ = 0
	maxx = max(k)
	for i in k:
		summ += maxx - i
	print(summ)


n = int(input())
money = [int(i) for i in input().split()]
max_num = max(money)
s = 0
for e in money:
	s += max_num - e
print(s)


n = int(input())
lis = list(map(int, input().split()))
count = 0
k = max(lis)
for i in lis:
	count = count + k - i
print(count)


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


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


people = int(input())
money = list(map(int, input().split()))
money.sort(reverse=True)
budget = 0
for i in range(people):
	incoming = money[0] - money[i]
	budget = budget + incoming
print(budget)


n = int(input())
a = [int(i) for i in input().split()]
m = 0
t = max(a)
for i in range(n):
	z = a[i]
	m = m + (t - z)
print(m)


z = []
u = 0
a = int(input())
z = list(map(int, input().split()))
m = max(z)
for i in range(a):
	o = m - z[i]
	u += o
print(u)


n = int(input())
mas = list(map(int, input().split()[:n]))
m = max(mas)
r = 0
res = 0
for i in range(0, len(mas)):
	r = m - mas[i]
	res += r
print(res)


x = int(input())
l = list(map(int, input().split()))
m = max(l)
sum = 0
for i in range(x):
	if l[i] != m:
		sum = sum + (m - l[i])
print(sum)


def Holiday_Of_Equality(li):
	Max = max(li)
	ans = 0
	for i in li:
		ans += Max - i
	return ans
n = input()
li = list(map(int, input().split()))
print(Holiday_Of_Equality(li))


n = int(input())
lis = list(map(int, input().split()))
m = max(lis)
t = sum([abs(lis[i] - m) for i in range(n)])
print(t)


try:
	n = int(input())
	x = list(map(int, input().split(' ')))
	k = max(x)
	while k in x:
		x.remove(k)
	s = 0
	for i in range(0, len(x)):
		s += k - x[i]
	print(s)
except:
	pass


def main():
	number_of_citizens = int(input())
	burles_processed = input()
	total_burles_processed = burles_processed.split(' ')
	total_money = 0
	for i in range(len(total_burles_processed)):
		total_burles_processed[i] = int(total_burles_processed[i])
		total_money += total_burles_processed[i]
	max_money = max(total_burles_processed)
	output = max_money * number_of_citizens - total_money
	print(output)
main()


n = int(input())
w = [int(i) for i in input().split()]
print(max(w) * len(w) - sum(w))


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


n = int(input())
lis = list(map(int, input().split()))
lis.sort()
s = 0
m = lis[-1]
for i in range(len(lis) - 1):
	s += m - lis[i]
print(s)


n = int(input())
l = list(map(int, input().split()))
l.sort()
l.reverse()
ans = 0
max = l[0]
for x in l:
	ans = ans + max - x
print(ans)


no_citizens = int(input())
welfares = input()
welfares = welfares.split()
welfares = [int(i) for i in welfares]
burles_spend = 0
for i in welfares:
	burles_spend += max(welfares) - i
print(burles_spend)


import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *

class Scanner:

	@staticmethod
	def int():
		return int(sys.stdin.readline().rstrip())

	@staticmethod
	def string():
		return sys.stdin.readline().rstrip()

	@staticmethod
	def map_int():
		return [int(x) for x in Scanner.string().split()]

	@staticmethod
	def string_list(n):
		return [input() for i in range(n)]

	@staticmethod
	def int_list_list(n):
		return [Scanner.map_int() for i in range(n)]

	@staticmethod
	def int_cols_list(n):
		return [int(input()) for i in range(n)]

class Math:

	@staticmethod
	def gcd(a, b):
		if b == 0:
			return a
		return Math.gcd(b, a % b)

	@staticmethod
	def lcm(a, b):
		return a * b // Math.gcd(a, b)

	@staticmethod
	def divisor(n):
		res = []
		i = 1
		for i in range(1, int(n ** 0.5) + 1):
			if n % i == 0:
				res.append(i)
				if i != n // i:
					res.append(n // i)
		return res

	@staticmethod
	def round_up(a, b):
		return -(-a // b)

	@staticmethod
	def is_prime(n):
		if n < 2:
			return False
		if n == 2:
			return True
		if n % 2 == 0:
			return False
		d = int(n ** 0.5) + 1
		for i in range(3, d + 1, 2):
			if n % i == 0:
				return False
		return True

class PriorityQueue:

	def __init__(self, l=[]):
		self.q = l
		heapq.heapify(self.q)
		return

	def push(self, n):
		heapq.heappush(self.q, n)
		return

	def pop(self):
		return heapq.heappop(self.q)

def pop_count(x):
	x = x - (x >> 1 & 6148914691236517205)
	x = (x & 3689348814741910323) + (x >> 2 & 3689348814741910323)
	x = x + (x >> 4) & 1085102592571150095
	x = x + (x >> 8)
	x = x + (x >> 16)
	x = x + (x >> 32)
	return x & 127
MOD = int(1000000000.0) + 7
INF = int(1000000000000000.0)

def main():
	_ = Scanner.int()
	A = Scanner.map_int()
	m = max(A)
	print(sum([m - a for a in A]))
main()


def list_from_input():
	return list(map(int, input().split()))

def solve(n, a):
	amount = 0
	max_cash = max(a)
	for a_i in a:
		amount += max_cash - a_i
	return amount

def main():
	n = int(input())
	a = list_from_input()
	print(solve(n, a))
main()


n = int(input())
l = list(map(int, input().split()))
ans = 0
for f in range(n):
	if l[f] < max(l):
		ans += max(l) - l[f]
print(ans)


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


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


input()
nums = list(map(int, input().split(' ')))
m = max(nums)
print(sum(map(lambda x: m - x, nums)))


N = int(input())
a = list(map(int, input().split()))
mm = max(a)
result = 0
for x in a:
	result += mm - x
print(result)


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


a = int(input())
numbers = list(map(int, input().split()))
numbers.sort()
x = 0
for i in range(0, a):
	x = x + numbers[a - 1] - numbers[i]
print(x)


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


n = input().strip()
n = int(n)
c = list(map(int, input().strip().split(' ')))
max_com = max(c)
sum = 0
for x in c:
	sum = sum + max_com - x
print(sum)


input()
li = list(map(int, input().split()))
print(sum([max(li) - i for i in li]))


int(input())
a = [int(i) for i in input().split()]
sums = 0
for i in a:
	sums += max(a) - i
print(sums)


_ = input()
x = input().split(' ')
test = []
for z in x:
	test.append(int(z))
most = max(test)
out = 0
for t in test:
	out += most - t
print(out)


n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
r = 0
for i in range(1, n):
	r += l[0] - l[i]
print(r)


n = int(input())
cit = list(map(int, input().split()))
mx = max(cit)
k = 0
for i in cit:
	k += mx - i
print(k)


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


n = int(input())
x = [int(q) for q in input().split()]
c = max(x)
ans = 0
for i in range(len(x)):
	ans += c - x[i]
print(ans)


n = int(input())
l = list(map(int, input().split()))
l.sort()
last = l[-1]
result = 0
for i in l:
	if i == last:
		break
	result += last - i
print(result)


N = int(input())
list = list(input().split())
list = [int(x) for x in list]
maxlist = max(list)
count = 0
for x in list:
	count = count + maxlist - x
print(count)


n = int(input().strip())
wellfares = [k for k in map(int, input().strip().split())]
max_welf = -1
for w in wellfares:
	max_welf = max(max_welf, w)
summ = 0
for w in wellfares:
	summ += abs(w - max_welf)
print(summ)


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


n = int(input())
l = list(map(int, input().split(' ')))
count = 0
d = []
for i in range(len(l)):
	if l[i] < max(l):
		d.append(max(l) - l[i])
print(sum(d))


n = int(input())
b = list(map(int, input().split()))
m = -1
s = 0
for i in b:
	if i > m:
		m = i
	s += i
r = n * m - s
print(r)


n = int(input())
q = list(map(int, input().split()))
c = 0
z = max(q)
for i in q:
	c += z - i
print(c)


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


_ = input()
citi = list(map(int, input().split()))
c_max = max(citi)
tot = 0
for _ in citi:
	tot += c_max - _
print(tot)


n = int(input())
b = [int(i) for i in input().split(' ')]
maxi = 0
for i in b:
	if i > maxi:
		maxi = i
count = 0
for i in b:
	count += maxi - i
print(count)


a = int(input())
b = input()
b = b.split(' ')
for huy in range(a):
	b[huy] = int(b[huy])
c = max(b) * a
sum = 0
for i in range(a):
	sum += b[i]
print(c - sum)


from sys import stdin, stdout
money = 0
n = int(stdin.readline().rstrip())
g = []
i = 0
nums = stdin.readline().rstrip().split()
nums = [int(x) for x in nums]
maximum = max(nums)
for i in nums:
	if i < maximum:
		money += maximum - i
stdout.write(str(money))


citizen = int(input())
kekayaan = map(int, input().split())
welfare = []
count = 0
burles = 0
for i in kekayaan:
	welfare.append(i)
welfare.sort()
while count < len(welfare) - 1:
	burles += welfare[-1] - welfare[count]
	count += 1
print(int(burles))


a = int(input())
c = input().split()
Sum = 0
v = []
for i in c:
	v.append(int(i))
for b in v:
	Sum += max(v) - b
print(Sum)


people = int(input())
money = input()
array = money.split(' ')
maxMoney = 0
result = 0
for i in array:
	try:
		if maxMoney < int(i):
			maxMoney = int(i)
	except ValueError:
		continue
for i in array:
	try:
		result += maxMoney - int(i)
	except ValueError:
		continue
print(result)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def gcd(a, b):
	if a == b:
		return a
	while b > 0:
		(a, b) = (b, a % b)
	return a

def lcm(a, b):
	return abs(a // gcd(a, b) * b)

def solve():
	n = int(inp())
	ar = lis()
	m = max(ar)
	s = 0
	for i in ar:
		s += m - i
	print(s)
solve()


n = int(input())
a = [int(i) for i in input().split()]
maxim = max(a)
S = 0
for i in a:
	if i < maxim:
		S += maxim - i
print(S)


n = int(input())
seq = list(map(int, input().split()))
border = max(seq)
money = 0
for i in seq:
	money += border - i
print(money)


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


citizens_input = input()
citizens_welfare_input = input()
citizens = int(citizens_input)
citizens_welfare_list = citizens_welfare_input.split()

def find_max():
	max = int(citizens_welfare_list[0])
	for num in citizens_welfare_list:
		if max <= int(num):
			max = int(num)
	return max

def min_spend():
	max_welfare = find_max()
	total = 0
	if citizens == 1:
		print(total)
	else:
		for welfare in citizens_welfare_list:
			total += max_welfare - int(welfare)
		print(total)
min_spend()


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)


import sys, math, string
input = sys.stdin.readline
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split().strip())
M = lambda : map(int, input().split())
n = int(input())
l = L()
k = max(l)
print(k * n - sum(l))


def solve2(welfare, n):
	welfare.sort()
	sumnum = 0
	for i in range(n):
		sumnum = sumnum + (welfare[-1] - welfare[i])
	return sumnum
n = int(input())
welfare = list(map(int, input().split(' ')))
print(solve2(welfare, n))


kol = int(input())
zapr = [int(i) for i in input().split()]
maxim = max(zapr)
counter = 0
for elem in zapr:
	if elem < maxim:
		counter += maxim - elem
print(counter)


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


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


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


n = int(input())
a = [int(i) for i in input().split()]
d = max(a)
sum = 0
for i in range(n):
	sum += d - a[i]
print(sum)


n = int(input())
e = list(map(int, input().split()))
m = max(e)
c = 0
for i in range(0, n):
	mon = m - e[i]
	c += mon
print(c)


mas = []
i = 0
n = int(input())
count = input().split(' ')
mas = [int(x) for x in count]
mas.sort()
max_count = max(mas)
for element in mas:
	i += max_count - element
print(i)


n = int(input())
l = list(map(int, input().strip().split()))
r = []
for i in range(n):
	a = max(l) - min(l)
	r.append(a)
	l.pop(l.index(min(l)))
print(sum(r))


n = int(input())
money = list(map(int, input().strip().split()))
maxi = int(max(money))
li = []
for i in money:
	temp = maxi - i
	li.append(temp)
print(sum(li))


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


n = int(input())
a = [int(x) for x in input().split()]
m = max(a)
if len(a) == 1:
	print(0)
else:
	s = 0
	for i in a:
		s = s + m - i
	print(s)


input()
generosidad = sorted(list(map(int, input().split())))
cantidad = 0
for i in range(len(generosidad) - 1):
	cantidad += generosidad[len(generosidad) - 1] - generosidad[i]
print(cantidad)


s = int(input())
A = [int(x) for x in input().split()]
A.sort()
x = 0
for i in range(s - 1):
	x += A[s - 1] - A[i]
print(x)


n = int(input())
a = list(map(int, input().split()))
a_ = list(map(lambda x: x - max(a), a))
print(-sum([x for x in a_ if x < 0]))


n = int(input())
a = [int(x) for x in input().split()]
b = max(a)
sum = 0
for i in range(n):
	sum += b - a[i]
print(sum)


a = int(input())
mylist = list(map(int, input().split()))
max_list = max(mylist)
sum = 0
for i in range(len(mylist)):
	c = max_list - mylist[i]
	sum += c
print(sum)


import sys
input = lambda : sys.stdin.readline()
import functools

@functools.lru_cache(maxsize=10000)
def Main(n):
	A = list(map(int, input().split()))
	A.sort()
	mx = A[len(A) - 1]
	sm = 0
	for i in range(n):
		sm += abs(A[i] - mx)
	print(sm)
n = int(input())
Main(n)


n = int(input())
xs = [int(x) for x in input().split()]
happiest = max(xs)
bs = sum([happiest - x for x in xs])
print(bs)


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


num_citizens = int(input())
welfares = list(map(int, input().split(' ')))
max_welfare = max(welfares)
amount = 0
for wel in welfares:
	amount += max_welfare - wel
print(amount)


from sys import stdin as fin
n = int(fin.readline())
nums = tuple(map(int, fin.readline().split()))
mx = max(nums)
res = sum((mx - a for a in nums))
print(res)


z = input
z()
l = sorted(map(int, z().split()))[::-1]
c = 0
x = l[0]
for i in l:
	c += x - i
print(c)


n = int(input(''))
citizens = input('').split(' ')
for i in range(n):
	citizens[i] = int(citizens[i])
sum = 0
for citizen in citizens:
	sum += max(citizens) - citizen
print(sum)


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


citizens = input()
burles = input().split()
small = []
largest = 0
for x in burles:
	if int(x) >= largest:
		largest = int(x)
for i in burles:
	if int(i) < largest:
		small.append(int(i))
total = 0
for num in small:
	if int(num) < largest:
		total += largest - int(num)
print(total)


import math
from collections import *
import sys
from functools import reduce

def get_ints():
	return map(int, input().strip().split())

def get_list():
	return list(get_ints())

def get_string():
	return list(input().strip().split())

def printxsp(*args):
	return print(*args, end='')

def printsp(*args):
	return print(*args, end=' ')
UGLYMOD = int(1000000000.0) + 7
SEXYMOD = 998244353
MAXN = int(100000.0)
n = int(input())
li = get_list()
mx = max(li)
ans = 0
for i in li:
	ans += mx - i
print(ans)


input()
wel_citz = [int(i) for i in input().split()]
a = 0
for j in range(len(wel_citz)):
	a = a + (max(wel_citz) - wel_citz[j])
print(a)


n = int(input())
a = list(map(int, input().strip().split()))[:n]
max_a = a[0]
for data in a:
	if data > max_a:
		max_a = data
count = 0
for i in range(n):
	count += max_a - a[i]
print(count)


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


n = int(input())
max = 0
output = 0
list1 = list(map(int, input().split()))
for items in list1:
	if items > max:
		max = items
for items in list1:
	output += max - items
print(output)


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


n = int(input())
l = [int(x) for x in input().split()]
l.sort()
a = []
for s in l:
	if s < max(l):
		a.append(s)
m = max(l)
q = l.count(m)
print((n - q) * m - sum(a))


n = int(input())
brs = list(map(int, input().split(' ')))
m = max(brs)
ans = sum([m - i for i in brs])
print(ans)


x = int(input())
wealths = [int(x) for x in input().split()]
y = max(wealths)
z = x * y
sum = 0
for wealth in wealths:
	sum = sum + wealth
p = z - sum
print(p)


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


n = int(input())
lst = [int(i) for i in input().split(' ')]
m = max(lst)
res = 0
for i in lst:
	if i != m:
		res += m - i
print(res)


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


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


n = int(input())
L = [int(x) for x in input().split()]
num = 0
t = max(L)
for i in range(len(L)):
	num = num + t - L[i]
print(num)


n = input()
s = input()
numbers = list(map(int, s.split()))
max = 0
ans = 0
for i in numbers:
	if i > max:
		max = i
for i in numbers:
	ans += max - i
print(ans)


def king(n, ar):
	sum = 0
	for i in range(len(ar)):
		if ar[i] != max(ar):
			sum += max(ar) - ar[i]
	return sum
a = int(input())
arr = list(map(int, input().strip().split()))
ans = king(a, arr)
print(ans)


import sys
r = lambda : sys.stdin.readline().strip()
N = int(r())
ns = [int(n) for n in r().split()]
maximum = max(ns)
sys.stdout.write(str(sum((maximum - n for n in ns))) + '\n')


n = int(input())
inp = input()
lst = list()
sum = 0
for i in inp.split(' '):
	lst.append(int(i))
lst.sort()
i = 0
while i <= n - 2:
	sum = sum + lst[n - 1] - lst[i]
	i = i + 1
print(sum)


n = input()
x = input()
number = x.split()
container = 0
total = 0
if int(n) == 1:
	print('0')
else:
	for i in range(0, int(n)):
		if int(number[i]) > container:
			container = int(number[i])
		total = total + int(number[i])
	need = int(n) * container
	answer = need - total
	print(answer)


input()
a = sorted(map(int, input().split(' ')))
ans = 0
for i in a[:len(a) - 1]:
	k = a[-1] - i
	ans = ans + k
print(ans)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
sys.setrecursionlimit(100000000)
ii = lambda : int(input())
si = lambda : input()
jn = lambda x, l: x.join(map(str, l))
sl = lambda : list(map(str, input().strip()))
mi = lambda : map(int, input().split())
mif = lambda : map(float, input().split())
lii = lambda : list(map(int, input().split()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
mod = 1000000007
n = ii()
arr = lii()
count = 0
a = max(arr)
for ele in arr:
	count += a - ele
print(count)


def r(t=int):
	return list(map(t, input().split()))

def ri(t=int):
	return t(input())

def cd(it):
	ret_val = dict()
	for v in it:
		ret_val[v] = ret_val.get(v, 0) + 1
	return ret_val
n = ri()
a = r()
m = max(a)
ans = 0
for ai in a:
	ans += m - ai
print(ans)


n = int(input())
t = list(map(int, input().split()))
mx = t[0]
s = 0
for i in t:
	mx = max(mx, i)
	s += i
print(mx * n - s)


n = int(input())
count = 0
l = list(map(int, input().split()))
mxm = max(l)
for i in range(n):
	count += mxm - l[i]
print(count)


input()
z = list(map(int, input().split()))
large = max(z)
print(sum([abs(i - large) for i in z]))


n = int(input())
l = list(map(int, input().strip().split()))
z = max(l)
x = list(map(lambda a: z - a, l))
print(sum(x))


def holiday_of_equality(a):
	vmax = max(a)
	return vmax * len(a) - sum(a)
n = int(input())
a = list(map(int, input().split()))
result = holiday_of_equality(a)
print(result)


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


n = int(input())
x = [int(i) for i in input().split()]
for i in range(n - 1):
	for j in range(i + 1, n):
		if x[i] < x[j]:
			(x[i], x[j]) = (x[j], x[i])
jlh = 0
for i in x:
	jlh += x[0] - i
print(jlh)


n = int(input())
a = [int(x) for x in input().split()]
maxi = 0
for x in a:
	if x > maxi:
		maxi = x
c = 0
for x in a:
	c += maxi - x
print(c)


n = int(input())
k = input()
f = k.split(' ')
ar = []
i = 0
while len(f) > i:
	ar.append(int(f[i]))
	i += 1
ar.sort()
i = 0
ans = 0
while len(ar) > i:
	ans += ar[n - 1] - ar[i]
	i += 1
print(ans)


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


hole = int(input())
foinni = list(map(int, input().split()))
bighole = max(foinni)
taka = 0
for fokir in foinni:
	taka += bighole - fokir
print(taka)


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


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


kol = input()
money = input()
if kol == 1:
	print(0)
else:
	nums = money.split(' ')
	maxm = 0
	for (i, elem) in enumerate(nums):
		nums[i] = int(elem)
		if nums[i] > maxm:
			maxm = nums[i]
	summ = 0
	for el2 in nums:
		summ += maxm - el2
	print(summ)


n = int(input())
cit = input()
cit = cit.split(' ')
t = []
for x in cit:
	t.append(int(x))
t = sorted(t)
spend = 0
for x in t:
	spend += t[-1] - x
print(spend)


a = int(input())
b = list(map(int, input().split()))
c = max(b)
cpt = 0
for e in b:
	cpt += c - e
print(cpt)


cit = int(input())
rub = [int(x) for x in input().split()]
total = 0
maxMoney = max(rub)
for r in rub:
	total += maxMoney - r
print(total)


n = int(input())
lista = [int(i) for i in input().split(' ')]
najveci = max(lista)
zbroj = 0
if n == 1:
	print(0)
else:
	for i in lista:
		if i < najveci:
			zbroj = zbroj + (najveci - i)
	print(zbroj)


n = int(input())
arr = list(map(int, input().split()))
ans = 0
x = max(arr)
if len(arr) == 1:
	print(0)
else:
	for i in arr:
		ans += abs(i - x)
	print(ans)


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


n = int(input())
a = [int(i) for i in input().split()]
mx = max(a)
res = 0
for i in a:
	res += mx - i
print(res)


from sys import stdin
n = int(stdin.readline())
data = list(map(int, stdin.readline().rstrip().split()))
print(max(data) * n - sum(data))


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


def func(n):
	k = list(map(int, input().split()))
	richest = max(k)
	counter = 0
	for i in k:
		if i != richest:
			counter += richest - i
	print(counter)
n = int(input())
func(n)


x = int(input())
a = [int(num) for num in input().split()]
c = max(a)
count = 0
for i in range(len(a)):
	if a[i] < c:
		r = c - a[i]
		count += r
		r = 0
print(count)


n = int(input())
l = [int(x) for x in input().split()]
print(sum([max(l) - l[i] for i in range(len(l))]))


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


n = int(input())
lst = list(map(int, input().strip().split(' ')))
lst.sort()
count = 0
for j in lst:
	if j < lst[-1]:
		count += lst[-1] - j
print(count)


inp = input()
inp1 = list(map(int, input().split()))
Max = max(inp1)
out = int()
if len(inp1) > 1:
	for x in inp1:
		out = out + Max - x
	print(out)
else:
	print(0)


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


n = int(input())
arr = input()
arr = arr.split(' ')
arr = list(map(int, arr))
ma = max(arr)
ans = 0
if n == 1:
	ans = 0
else:
	for i in arr:
		if i != ma:
			ans = ans + ma - i
		else:
			continue
print(ans)


n = int(input())
lst = list(map(int, input().split()))
lst.sort()
sum = 0
for i in range(n):
	sum = sum + lst[n - 1] - lst[i]
print(sum)


n = int(input())
ipt = [int(x) for x in input().split()]
accumulator = 0
max = max(ipt)
for (i, val) in enumerate(ipt):
	accumulator += max - val
print(accumulator)


n = int(input())
deng = list(map(int, input('').split()))
deng_max = max(deng)
summ_p = 0
for i in range(len(deng)):
	summ_p = summ_p + deng_max - deng[i]
print(summ_p)


n = int(input())
a = []
a = list(map(int, input().split()))
i = 0
a.sort()
l = a.pop(n - 1)
for s in a:
	if s != l:
		i = i + (l - s)
print(i)


n = int(input())
a = [int(i) for i in input().split()]
ma = max(a)
s = 0
j = 0
for i in range(n):
	if a[i] != ma:
		j += 1
		s += a[i]
print(ma * j - s)


def INPUT():
	return [int(x) for x in input().split(' ')]

def main():
	n = int(input())
	List = INPUT()
	mx = max(List)
	ans = 0
	for elem in List:
		ans += abs(mx - elem)
	print(ans)
main()


d = int(input())
x = [int(x) for x in input().split()]
e = 0
for i in range(d):
	if max(x) != x[i]:
		e += max(x) - x[i]
print(e)


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


n = int(input())
welfare_list = [int(w) for w in input().split()]
highest = max(welfare_list)
ans = 0
for element in welfare_list:
	if element != highest:
		ans += highest - element
print(ans)


import sys
n = int(sys.stdin.readline().split()[0])
wealth = [int(i) for i in sys.stdin.readline().split()]
max_value = max(wealth)
total_cost = 0
for i in wealth:
	total_cost += max_value - i
print(total_cost)


n = map(int, input().split())
a = list(map(int, input().split()))
m = len(a)
S = 0
z = 0
ma = max(a)
for i in range(m):
	if a[i] < ma:
		z = ma - a[i]
		S += z
print(S)


n = int(input())
num = input()
arr = []
count = 0
for i in range(0, len(num)):
	if num[i] == ' ':
		arr.append(int(num[count:i]))
		count = i + 1
	elif i == len(num) - 1:
		arr.append(int(num[count:len(num)]))
arr.sort()
count = 0
for i in arr:
	diff = arr[len(arr) - 1] - i
	count += diff
print(count)


times = int(input())
ppl = [int(i) for i in input().split()]
moneySpend = 0
for i in range(0, times):
	lowestMuch = min(ppl)
	lowestIndex = ppl.index(min(ppl))
	maxMuch = max(ppl)
	maxIndex = ppl.index(max(ppl))
	ppl[lowestIndex] += maxMuch - lowestMuch
	moneySpend += maxMuch - lowestMuch
print(moneySpend)


n = int(input())
l = [int(i) for i in input().split()[:n]]
m = max(l)
x = 0
for i in range(n):
	if l[i] == m:
		pass
	else:
		x += m - l[i]
print(x)


n = int(input())
li = input().split(' ')
li = list(map(int, li))
target = max(li)
initial = sum(li)
print(n * target - initial)


(n, l) = (int(input()), sorted(list(map(int, input().split(' ')))))
print(sum((l[-1] - l[i] for i in range(n))))


from sys import stdin, stdout

def main():
	int_awal = int(input(''))
	inp = [int(i) for i in input().split(' ')]
	count = 0
	max_int = max(inp)
	if int_awal == 1:
		print(0)
	else:
		for i in range(len(inp)):
			if inp[i] == max_int:
				continue
			elif inp[i] < max_int:
				count += max_int - inp[i]
		print(count)
main()


kk = input()
gg = input()
arr1 = gg.split()
arr = []
for i in arr1:
	arr.append(int(i))
total = 0
g = max(arr)
for i in arr:
	gt = g - i
	total += gt
print(total)


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


N = int(input())
vals = list(map(int, input().split()[:N]))
mv = max(vals)
print(sum([mv - v for v in vals]))


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


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


n = int(input())
l1 = [int(i) for i in input().split(' ')]
t = max(l1)
sum = 0
for i in l1:
	m = t - i
	sum = sum + m
print(sum)


import sys
n = int(input())
a = list(map(int, sys.stdin.readline().split()))
max = 0
sum = 0
for i in a:
	sum += i
	if i > max:
		max = i
print(max * n - sum)


n = int(input())
N = [int(num) for num in input().split(' ', n - 1)]
a = max(N)
i = x = 0
while i < n:
	x = x + (a - N[i])
	i += 1
print(x)


import sys
from math import factorial as fact

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def minput():
	return map(int, input().split())

def listinput():
	return list(map(int, input().split()))
n = iinput()
l = listinput()
answer = max(l) * n - sum(l)
print(answer)


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


n = int(input())
l = list(map(int, input().split()))
p = []
r = max(l)
for i in range(n):
	p.append(r - l[i])
print(sum(p))


n = int(input())
a = list(map(int, input().split()))
a.sort()
max_element = max(a)
cnt = 0
i = 0
while i < len(a) - 1:
	cnt += max_element - a[i]
	i += 1
print(cnt)


x = []
z = int(input())
x = [int(i) for i in input().split()]
y = max(x)
count = 0
for i in range(z):
	count = count + (y - x[i])
print(count)


import sys
from random import choice, randint
inp = sys.stdin.readline
out = sys.stdout.write
flsh = sys.stdout.flush
sys.setrecursionlimit(10 ** 9)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def MI():
	return map(int, inp().strip().split())

def LI():
	return list(map(int, inp().strip().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines().strip()]

def LI_():
	return [int(x) - 1 for x in inp().strip().split()]

def LF():
	return [float(x) for x in inp().strip().split()]

def LS():
	return inp().strip().split()

def I():
	return int(inp().strip())

def F():
	return float(inp().strip())

def S():
	return inp().strip()

def pf(s):
	return out(s + '\n')

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def main():
	n = I()
	a = LI()
	mx = max(a)
	c = 0
	for i in a:
		c += mx - i
	pf(str(c))
main()


n = int(input())
a = list(map(int, input().split()))
out = 0
M = max(a)
for el in a:
	out += M - el
print(out)


a = int(input())
b = list(map(int, input().split()))
result = 0
for x in range(a):
	c = max(b) - b[x]
	result = result + c
print(result)


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


num_of_burls = input()
welfare = input()
here = welfare.split()
repeating = []
maximum = -1
summation = 0
for number in here:
	if int(number) > maximum:
		maximum = int(number)
for number in here:
	summation += maximum - int(number)
print(summation)


n = int(input())
wealthnesses = [int(x) for x in input().split()]
costs = 0
aim = max(wealthnesses)
for wealthness in wealthnesses:
	costs += aim - wealthness
print(costs)
exit()


n = int(input())
li = [int(x) for x in input().split()]
a = max(li)
ncount = 0
for num in li:
	ncount += a - num
print(ncount)


def main():
	n = input()
	s = list(map(int, input().split()))
	z = max(s)
	burles = 0
	for i in s:
		if i != z:
			burles += abs(z - i)
	print(burles)
main()


n = int(input())
arr = input().split()
size = len(arr)
for i in range(0, size):
	arr[i] = int(arr[i])
maxm = max(arr)
su = sum(arr)
print(maxm * size - su)


n = int(input(''))
c = [int(i) for i in input('').split()]
c = sorted(c)
out = 0
for i in c:
	out += c[n - 1] - i
print(out)


import math
import itertools
gh = lambda : map(int, input().split())
mod = 998244353
mod = int(mod)

def main():
	input()
	a = list(gh())
	mx = max(a)
	cnt = 0
	for i in a:
		cnt += mx - i
	print(cnt)
main()


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


n = input()
salary = [int(money) for money in input().split(' ')]
max_salary = max(salary)
adding = sum([max_salary - money for money in salary])
print(adding)


input()
a = sorted(map(int, input().split(' ')))
a.sort()
total = 0
for i in a:
	total += a[len(a) - 1] - i
print(total)


numofcitizen = int(input())
burles = list(map(int, input().split()))
max_value = max(burles)
minimum_b = 0
for money in burles:
	if money != max_value:
		minimum_b = minimum_b + (max_value - money)
print(minimum_b)


def f(ar):
	t = 0
	for i in ar:
		t += max(ar) - i
	print(t)
count = int(input())
a = list(map(int, input().rstrip().split()))
f(a)


n = int(input())
c = input().split()
ans = 0
for i in range(n):
	c[i] = int(c[i])
c.sort()
for i in c:
	ans += c[-1] - i
print(ans)


n = int(input())
listm = list(map(int, input().split()))
max1 = max(listm)
count = 0
for i in listm:
	j = max1 - i
	count += j
print(count)


n = int(input())
arr = list(map(int, input().split()))
count = 0
arr.sort()
for i in range(0, n - 1):
	count += arr[n - 1] - arr[i]
print(count)


n = int(input())
welfare = [int(item) for item in input().split()]
equalize = 0
for item in sorted(welfare):
	if sorted(welfare)[-1] != item:
		equalize += sorted(welfare)[-1] - item
print(equalize)


n = int(input())
l = list(map(int, input().split(' ')))
o = 0
for i in l:
	if i != max(l):
		o += max(l) - i
	else:
		continue
print(o)


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


n = int(input(''))
l = []
output = 0
for a in input('').split(' '):
	w = int(a)
	l.append(w)
p = max(l)
for a in l:
	output = output + p - a
print(output)


n = int(input())
if n > 1:
	a = input().split()
	b = list(map(int, a))
	b.sort()
	i = result = 0
	n = n - 1
	while i != n:
		result += b[n] - b[i]
		i += 1
	print(result)
else:
	print('0')


n = int(input())
a = list(map(int, input().split()))
d = 0
if n == 1:
	print(0)
	exit()
m = max(a)
for i in range(len(a)):
	c = m - a[i]
	d += c
print(d)


n = int(input())
l = list(map(int, input().split()))
mx = max(l)
count = 0
for item in l:
	if item < mx:
		result = mx - item
		count += result
print(count)


n = int(input())
arr = list(map(int, input().split()))
maxValue = max(arr)
count = 0
for x in arr:
	count += maxValue - x
print(count)


n = int(input())
s = list(map(int, input().split(' ')))
s.sort()
c = 0
for i in range(n):
	if s[i] < max(s):
		c += max(s) - s[i]
	else:
		break
print(c)


def Mayor(A):
	Mayor = -1
	for K in range(len(A)):
		if int(A[K]) > Mayor:
			Mayor = int(A[K])
	return Mayor
N = int(input(''))
Burles = input('')
Burles = Burles.split()
ReyCharlie = 0
Rico = Mayor(Burles)
for K in range(N):
	X = Rico - int(Burles[K])
	ReyCharlie = ReyCharlie + X
print(ReyCharlie)


a = int(input())
data = [int(y) for y in input().split()]
x = 0
y = 0
for i in range(len(data) - 1):
	for j in range(i + 1, len(data)):
		if data[i] > data[j]:
			(data[j], data[i]) = (data[i], data[j])
for i in range(len(data)):
	if data[i] == data[a - 1]:
		x += 0
		y += 0
	if data[i] < data[a - 1]:
		x = data[a - 1] - data[i]
		y += x
print(y)


m = int(input())
sost = list(map(int, input().split()))
reachest = 0
for citizen in sost:
	if citizen > reachest:
		reachest = citizen
gift = 0
for citizen in sost:
	gift += reachest - citizen
print(gift)


n = int(input())
l = []
l = list(map(int, input().strip().split()))[:n]
b = max(l)
c = 0
for i in l:
	d = abs(b - i)
	c = c + d
print(c)


n = int(input())
a = list(map(int, input().strip().split(' ')))
maxa = max(a)
cmax = a.count(maxa)
print(maxa * (n - cmax) - sum(a) + maxa * cmax)


n = int(input())
a = [int(i) for i in input().split()]
d = max(a)
sums = 0
for i in range(0, len(a)):
	sums = sums + (d - a[i])
print(sums)


def is_high(a):
	high = -1
	for i in a:
		if i > high:
			high = i
	return high
n = input()
n = int(n)
a = input().split()
b = []
for i in range(n):
	b.append(int(a[i]))
high = is_high(b)
ans = 0
for i in b:
	ans += high - i
print(ans)


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


vil = int(input())
cond = [int(p) for p in input().split()]
(toGive, m) = (0, max(cond))
for i in cond:
	toGive += m - i
print(toGive)


n = int(input())
M = list(map(int, input().split()))
if n == 1:
	print(0)
elif len(set(M)) == 1:
	print(0)
else:
	maxx = M[0]
	nb = 0
	for i in range(n - 1):
		if M[i] == M[i + 1]:
			nb += 1
	if nb != n - 1:
		for t in range(n):
			if M[t] > maxx:
				maxx = M[t]
		rs = 0
		for k in range(n):
			if M[k] != maxx:
				rs += M[k] - maxx
	print(abs(rs))


n = int(input())
A = [int(x) for x in input().split()]
num = 0
for i in range(n):
	num += max(A) - A[i]
print(num)


from fractions import Fraction
import sys
import bisect
import heapq
from math import *
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
import statistics
from statistics import mode
from functools import reduce
mod = 1000000007

def inp():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def graph(vertex):
	return [[] for i in range(0, vertex + 1)]

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def most_frequent(List):
	occurence_count = Counter(List)
	return occurence_count.most_common(1)[0][0]

def most_common(List):
	return mode(List)

def chinese_remainder(a, p):
	prod = reduce(op.mul, p, 1)
	x = [prod // pi for pi in p]
	return sum((a[i] * pow(x[i], p[i] - 2, p[i]) * x[i] for i in range(len(a)))) % prod

def createMatrix(rowCount, colCount, dataList):
	mat = []
	for i in range(rowCount):
		rowList = []
		for j in range(colCount):
			if dataList[j] not in mat:
				rowList.append(dataList[j])
		mat.append(rowList)
	return mat

def isprime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
import collections

def minimalFilps1(bits):
	n = len(bits)
	flipsFromLeft = [0 for i in range(n)]
	flipsFromRight = [0 for i in range(n)]
	flips = 0
	for i in range(0, n, 1):
		if bits[i] == '1':
			flips = flips + 1
		flipsFromLeft[i] = flips
	flips = 0
	i = n - 1
	while i >= 0:
		if bits[i] == '0':
			flips = flips + 1
		i = i - 1
		flipsFromRight[i] = flips
	minFlips1 = sys.maxsize
	for i in range(1, n, 1):
		if flipsFromLeft[i - 1] + flipsFromRight[i] < minFlips1:
			minFlips1 = flipsFromLeft[i - 1] + flipsFromRight[i]
	return minFlips1

def minimalFilps(bits):
	n = len(bits)
	flipsFromLeft = [0 for i in range(n)]
	flipsFromRight = [0 for i in range(n)]
	flips = 0
	for i in range(0, n, 1):
		if bits[i] == '0':
			flips = flips + 1
		flipsFromLeft[i] = flips
	flips = 0
	i = n - 1
	while i >= 0:
		if bits[i] == '1':
			flips = flips + 1
		i = i - 1
		flipsFromRight[i] = flips
	minFlips = sys.maxsize
	for i in range(1, n, 1):
		if flipsFromLeft[i - 1] + flipsFromRight[i] < minFlips:
			minFlips = flipsFromLeft[i - 1] + flipsFromRight[i]
	return minFlips

def oddn(n):
	for i in range(2, n + 1):
		if i % 2 != 0 and n % i == 0:
			return i
	return 3

def memoized(*args):
	if args in stored_results:
		return stored_results[args]
	else:
		result = stored_results[args] = fn(*args)
		return result
	return memoized
open_list = ['(']
close_list = [')']

def check(myStr):
	stack = []
	e = 0
	for i in myStr:
		if i in open_list:
			stack.append(i)
		elif i in close_list:
			pos = close_list.index(i)
			if len(stack) > 0:
				stack.pop()
				e += 1
	return e
n = int(input())
a = list(map(int, input().split()))
b = max(a)
a.remove(b)
for i in range(len(a)):
	a[i] = b - a[i]
if len(a) == 0:
	c = 0
c = sum(a)
print(c)
import operator
open_list = ['(']
close_list = [')']

def check(myStr):
	stack = []
	e = 0
	for i in myStr:
		if i in open_list:
			stack.append(i)
		elif i in close_list:
			pos = close_list.index(i)
			if len(stack) > 0:
				stack.pop()
				e += 1
	return e


n = int(input())
L = [int(x) for x in input().split()]
t = max(L)
print(sum((t - s for s in L)))


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


import sys
n = int(input())
arr = [int(x) for x in input().split()]
tmp = max(arr)
res = 0
for i in arr:
	res += max(arr) - i
print(res)
sys.exit(0)


n = int(input())
x = list(map(int, input().split()))
maxi = max(x)
count = 0
for i in x:
	if i < maxi:
		count += maxi - i
print(count)


class CodeforcesTask758ASolution:

	def __init__(self):
		self.result = ''
		self.welfare = []

	def read_input(self):
		input()
		self.welfare = [int(x) for x in input().split(' ')]

	def process_task(self):
		target = max(self.welfare)
		self.result = str(sum([target - x for x in self.welfare]))

	def get_result(self):
		return self.result
Solution = CodeforcesTask758ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


import math
import decimal
import sys
files = False
if files:
	sys.stdin = open('name.in', 'r')
	sys.stdout = open('name.out', 'w')
name1 = str(input())
ar = [int(i) for i in input().split()]
mx = max(ar)
print(mx * len(ar) - sum(ar))
sys.stdout.close()


n = map(int, input().split())
list1 = list(map(int, input().split()))
b = max(list1)
c = 0
for i in list1:
	c += b - i
print(c)


n = int(input())
welfare = list(map(int, input().split()))
max_welfare = max(welfare)
burl = 0
for i in welfare:
	if i < max_welfare:
		burl += max_welfare - i
print(burl)


n = int(input())
x = list(map(int, input().split()))
z = max(x)
l = list(map(lambda y: z - y, x))
print(sum(l))


def array(arr, struc):
	return list(map(struc, arr.split()))
n = int(input())
arr = array(input(), int)
mx = max(arr)
print(mx * n - sum(arr))


import logging
fmt = '%(levelname)s - %(name)s (line:%(lineno)s) - %(message)s'
formatter = logging.Formatter(fmt)
ch = logging.StreamHandler()
ch.setLevel(logging.ERROR)
ch.setFormatter(formatter)
logger = logging.getLogger('holiday_of_equality')
logger.setLevel(logging.ERROR)
logger.addHandler(ch)

def solve(s):
	max_w = max(s)
	return sum((max_w - x for x in s))

def main():
	n = int(input().strip())
	s = [int(x) for x in input().strip().split()]
	result = solve(s)
	print(result)
main()


n = int(input())
a = [int(i) for i in input().split()]
a.sort()
a.reverse()
ans = int()
for i in range(1, n):
	ans += a[0] - a[i]
print(ans)


input()
a = [int(m) for m in input().split()]
print(sum((max(a) - i for i in a)))


from functools import reduce
n = int(input())
a = list(map(int, input().rstrip().split()))
mx = reduce(max, a)
print(sum([mx - x for x in a]))


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


t = int(input())
a = list(map(int, input().split()))
m = max(a)
sum = 0
for i in a:
	if i < m:
		sum += m - i
	else:
		pass
print(sum)


n = int(input())
mat = input().split()
matn = []
sum = 0
for x in mat:
	matn.append(int(x))
matn.sort()
for i in matn[:n]:
	sum += matn[-1] - i
print(sum)


n = input()
x = [int(x) for x in input().split()]
x.sort()
max = x[-1]
a = len(x) * max - sum(x)
print(a)


n = int(input())
x = [int(t) for t in input().split()]
x.sort(reverse=True)
a = x[0]
cnt = 0
for i in x:
	b = abs(i - a)
	cnt += b
print(cnt)


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


import math

def get_primes(prime_supr):
	is_prime = [0] * 2 + [1] * prime_supr
	for i in range(2, int(math.sqrt(prime_supr)) + 1):
		if is_prime[i]:
			for j in range(i * i, prime_supr + 1, i):
				is_prime[j] = 0
	return is_prime
get_int = lambda : map(int, input().split())
n = int(input())
a = list(get_int())
print(max(a) * n - sum(a))


c = int(input())
l = list(map(int, input().split()))
max = 0
for i in l:
	if i > max:
		max = i
sum = 0
for i in l:
	sum = sum + (max - i)
print(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())
l = list(map(int, input().split()))
s = max(l)
ans = 0
for i in l:
	ans += abs(i - s)
print(ans)


s = int(input())
l = list(map(int, input().split()))
c = max(l)
f = 0
for i in range(s):
	f += c - l[i]
print(f)


n = int(input())
l = list(map(int, input().split()))
m = max(l)
s = 0
i = 0
while i < n:
	if l[i] != m:
		s += m - l[i]
		l[i] = m
	i += 1
print(s)


a = input()
b = input()
c = b.split()
d = list(map(int, c))
max_list = max(d)
add = 0
for r in d:
	add = add + max_list - r
print(add)


n = int(input())
citizens = [int(x) for x in input().split()]
rich = max(citizens)
money = 0
for citizen in citizens:
	money += rich - citizen
print(money)


n = int(input())
a = [int(x) for x in input().split()]
p = max(a)
sum = 0
for i in a:
	sum += abs(p - i)
print(sum)


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


n = int(input())
vals = [int(x) for x in input().split()]
maxV = max(vals)
s = 0
for v in vals:
	s += maxV - v
print(s)


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


_ = input()
array = [int(item) for item in input().split()]
maxV = max(array)
result = 0
for item in array:
	result += maxV - item
print(result)


_ = input()
arr = list(map(int, input().split()))
max_element = max(arr)
sum = 0
for i in arr:
	sum += max_element - i
print(sum)


isDebug = False
n = int(input())
a = [int(x) for x in input().split()]
a = sorted(a)
m = a[len(a) - 1]
t = 0
for i in range(0, len(a) - 1):
	t = t + (m - a[i])
print(f'{t}')


a = int(input())
s = list(map(int, input().split()))
ma = max(s)
count = 0
for i in s:
	if i < ma:
		count = count + ma - i
print(count)


n = int(input())
l1 = list(map(int, input().split()))
y = max(l1)
l2 = []
for i in range(len(l1)):
	z = y - l1[i]
	l2.append(z)
print(sum(l2))


class Main:
	n = int(input())
	a = input().rstrip().split(' ')
	for i in range(n):
		a[i] = int(a[i])
	s = 0
	a_max = max(a)
	for a_i in a:
		s += a_max - a_i
	print(s)
Main()


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


x = int(input())
y = [int(i) for i in input().split()]
a = sum(y)
b = max(y)
print(x * b - a)


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


n = int(input())
l = input().split()
a = []
for i in range(n):
	a.append(int(l[i]))
M = max(a)
ans = 0
for i in range(n):
	ans += -a[i] + M
print(ans)


n = int(input())
c = list(map(int, input().split()))
d = max(c)
tot = 0
for i in range(len(c)):
	tot += d - c[i]
print(tot)


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())
l = [int(i) for i in input().split()]
m = max(l)
t = 0
for i in l:
	t += abs(i - m)
print(t)


n = int(input())
welfare = tuple(map(int, input().split()))
max_value = max(welfare)
ans = 0
for i in welfare:
	ans += max_value - i
print(ans)


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


n = int(input())
a = [int(i) for i in input().split()]
print((n - 1) * max(a) - (sum(a) - max(a)))


n = int(input())
lis = list(map(int, input().split()))
result = 0
maxi = max(lis)
for i in lis:
	result = result + (maxi - i)
print(result)


n = int(input())
ci = input().split()
cil = []
mymax = 0
for i in range(n):
	cil.append(int(ci[i]))
	if int(ci[i]) > mymax:
		mymax = int(ci[i])
mysum = 0
for i in range(n):
	mysum += mymax - cil[i]
print(mysum)


n = int(input())
a = list(map(int, input().split()))
c = 0
b = 0
for i in a:
	if i != max(a):
		c = max(a) - i
		b += c
	else:
		i = 0
print(b)


n = int(input())
a = [int(x) for x in input().split()]
mx = max(a)
print(sum([mx - i for i in a if i != mx]))


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


mx = 0
sm = 0
n = int(input())
s = input().split(' ')
for i in range(n):
	k = int(s[i])
	mx = max(k, mx)
	sm += k
bonus = mx * n - sm
print(bonus)


def main():
	n = int(input())
	m = [int(i) for i in input().split()]
	ans = 0
	for i in range(n):
		if m[i] < max(m):
			ans += max(m) - m[i]
	print(ans)
main()


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


n = int(input())
inp = input()
nums = inp.split()
out = 0
thelargest = 0
for num in nums:
	if int(num) > thelargest:
		thelargest = int(num)
for i in range(n):
	out = out + (thelargest - int(nums[i]))
print(out)


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


a = int(input())
b = [int(x) for x in input().split()]
c = max(b)
sum = 0
for i in b:
	if i == c:
		sum = sum + 0
	else:
		sum = sum + (c - i)
print(sum)


n = int(input())
a = list(map(int, input().split()))
b = max(a)
c = a.remove(b)
d = sum(a)
e = len(a) * b
print(e - d)


n = int(input())
a = [int(x) for x in input().split()]
new_welfare = max(a)
money = 0
for i in range(n):
	money += new_welfare - a[i]
print(money)


n = int(input())
l = list(map(int, input().split(' ')))
m = max(l)
sum = 0
for i in range(0, n):
	if n == 0:
		print('0')
		break
	else:
		diff = m - l[i]
		sum += diff
print(sum)


n = int(input())
max = 0
s = 0
l = [int(x) for x in input().split()]
for i in range(n):
	if l[i] > max:
		s += i * (l[i] - max)
		max = l[i]
	s += max - l[i]
print(s)


n = int(input())
t = list(map(int, input().split()))
max = max(t)
if n == 1:
	print(0)
else:
	s = 0
	for i in t:
		if i < max:
			s += max - i
	print(s)


n = int(input())
a = [int(i) for i in input().split()]
x = a[0]
for i in range(n):
	if a[i] > x:
		x = a[i]
k = 0
for i in range(n):
	k += x - a[i]
print(k)


n = int(input())
L = [int(d) for d in input().split()]
s = 0
for i in L:
	s += i
print(n * max(L) - s)


n = int(input())
l = sorted(list(map(int, input().split())))
k = l[n - 1]
print(sum((abs(x - k) for x in l if abs(x - k) >= 0)))


n = int(input())
welfare = list(map(int, input().split(' ')))
max_welfare = max(welfare)
answer = 0
for people in welfare:
	answer += max_welfare - people
print(answer)


value = int(input())
values = input()
values = values.split()
values = [int(i) for i in values]
values.sort()
values = [values[-1] - i for i in values]
print(sum(values))


input()
t = list(map(int, input().split()))
print(sum(map(lambda x: max(t) - x, t)))


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


n = int(input())
a = [int(x) for x in input().split(' ')]
a = sorted(a, reverse=True)
total = 0
for i in range(1, n):
	total += a[0] - a[i]
print(total)


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


n = int(input())
arr = list(map(int, input().split()))
maxnum = max(arr)
total = 0
for x in arr:
	total += maxnum - x
print(total)


n = int(input())
f = list(map(int, input().split()))
lis = [max(f) - item for item in f]
print(sum(lis))


x = int(input())
l = list(map(int, input().split()))
p = max(l)
tot = 0
for i in l:
	tot += p - i
print(tot)


x = int(input())
y = input().split()
lst = []
jlh = 0
for i in range(x):
	lst.append(int(y[i]))
lst.sort()
for j in range(x - 1):
	jlh += lst[len(lst) - 1] - lst[j]
print(jlh)


input()
a = [int(i) for i in input().split()]
pay = 0
x = max(a)
for (i, j) in enumerate(a):
	if j < x:
		a[i] += x - j
		pay += x - j
print(pay)


n = int(input())
w = [int(x) for x in input().split()]
w.sort()
output = 0
for i in range(n):
	output += w[-1] - w[i]
print(output)


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


def maximo(arr):
	m = 0
	for a in arr:
		if int(a) >= m:
			m = int(a)
	return m
n = int(input())
ns = input().split(' ')
maximo = maximo(ns)
s = 0
for i in ns:
	if int(i) != maximo:
		s += maximo - int(i)
print(s)


n = int(input())
a = map(int, input().split())
a = list(a)
b = max(a)
total = 0
for i in range(n):
	if a[i] != b:
		total = total + b - a[i]
	else:
		total = total
print(total)


a = input()
b = input()
c = list()
b = b.split()
for x in b:
	c.append(int(x))
max = 0
for x in c:
	if x > max:
		max = x
tr = 0
for x in c:
	if x < max:
		tr = tr + (max - x)
print(tr)


i = input()
p = input().split()
o = int(max(p))
l = 0
k = [int(x) for x in p]
n = max(k)
z = 0
for j in k:
	z = z + (n - j)
print(z)


n = int(input())
data = sorted([int(x) for x in input().split()])
y = data[-1]
x = 0
for i in range(len(data) - 1):
	x += y - data[i]
print(x)


n = int(input())
l = [int(i) for i in input().split()]
x = 0
k = max(l)
for i in range(len(l)):
	x = x + (k - l[i])
print(x)


n = int(input())
a = [int(a) for a in input().split()]
a.sort(reverse=True)
b = 0
for i in range(n):
	if a[0] == a[i]:
		b = b
	else:
		b += a[0] - a[i]
print(b)


num_citizens = int(input())
welfares = input().split()
welfares = [int(x) for x in welfares]
needs = [max(welfares) - x for x in welfares]
print(sum(needs))


n = int(input())
c = [int(i) for i in input().split()]
t = 0
ma = 0
for i in c:
	if i > ma:
		ma = i
for i in c:
	t += ma - i
print(t)


a = int(input())
b = input() + ' '
c = []
e = 0
f = 0
for i in range(len(b)):
	if b[i] == ' ':
		c.append(int(b[e:i]))
		e = i + 1
for i in range(len(c)):
	f = f + c[i]
g = max(c)
print(g * a - f)


count = int(input())
arr = input().split()
biggest = 0
sum1 = 0
for i in arr:
	i = int(i)
	if i > biggest:
		biggest = i
	sum1 += i
print(count * biggest - sum1)


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


n = int(input())
list1 = list(map(int, input().split(' ')))
list1.sort()
list1.reverse()
a = list1[0]
count = 0
for i in list1:
	b = a - i
	count = count + b
print(count)


def equality(n, a):
	maxx = max(a)
	return sum([maxx - el for el in a])
nn = int(input())
aa = list(map(int, input().split()))
print(equality(nn, aa))


citizens = int(input())
string = input()
numbers = string.split(' ')
for x in range(citizens):
	numbers[x] = int(numbers[x])
s = 0
for x in numbers:
	s += max(numbers) - x
print(s)


n = int(input())
welfare = list(map(int, input().split()))
welfare.sort()
if n == 1:
	print(0)
else:
	count = 0
	for w in welfare[:-1]:
		count += welfare[-1] - w
	print(count)


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 = [int(x) for x in input().split()]
maxi = max(a)
ans = 0
for i in a:
	ans += maxi - i
print(ans)


n = int(input())
ar = [int(num) for num in input().split()]
m = max(ar)
a = 0
for i in ar:
	a += m - i
print(a)


n = int(input())
l = list(map(int, input().split()))
Max = max(l)
c = 0
for i in l:
	c += abs(Max - i)
print(c)


n = int(input())
a = input().split()
a = [int(i) for i in a]
b = max(a)
c = 0
for i in range(len(a)):
	c = c + b - a[i]
print(c)


N = int(input())
array = list(map(int, input().split()))
maxs = max(array)
ans = 0
for i in array:
	ans += maxs - i
print(ans)


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


from functools import reduce
n = int(input())
expense_list = list(map(int, input().split()))
print(max(expense_list) * n - reduce(lambda x, y: x + y, expense_list))


n = int(input())
p = input()
p = p.split()
s = 0
for i in range(n):
	p[i] = int(p[i])
p.sort()
for i in range(n):
	s += p[n - 1] - p[i]
print(s)


(citizens, welfare) = (int(input()), list(map(int, input().split())))
(largest, burles) = (max(welfare), 0)
for x in range(citizens):
	burles = burles + abs(welfare[x] - largest)
print(burles)


n = int(input())
a = list(map(int, input().split()))
k = 0
i = 0
x = 0
while i < n:
	if a[i] > k:
		k = a[i]
	i = i + 1
i = 0
while i < n:
	x += k - a[i]
	i = i + 1
print(x)


def numint(x):
	return int(x)
n = int(input())
lst = input().split()
maxnum = max(map(numint, lst))
summ = 0
for i in map(numint, lst):
	summ += abs(int(i) - int(maxnum))
print(summ)


n = int(input())
a = [int(i) for i in input().split()]
gr = max(a)
a.sort()
burles = 0
for i in range(len(a)):
	burles += gr - a[i]
print(burles)


n = int(input())
ws = list(map(int, input().split(' ')))
print(sum(map(lambda x: max(ws) - x, ws)))


n = input()
lista = list(map(int, input().split()))
k = max(lista)
sum = 0
for i in lista:
	sum += k - i
print(sum)


n = int(input())
S = list(map(int, input().split()))
count = 0
for i in range(n):
	if max(S) > S[i]:
		count += max(S) - S[i]
print(count)


n = int(input())
lis = list(map(int, input().split(' ')))[:n]
higest = max(lis)
tot = 0
for i in lis:
	if i < higest:
		tot += higest - i
print(tot)


n = int(input())
a = [int(h) for h in input().split()]
total = 0
for i in range(n):
	if a[i] < max(a):
		total += max(a) - a[i]
print(total)


n = int(input())
a = list(map(int, input().split()))
m = max(a)
sum = 0
for citizen in range(n):
	sum += m - a[citizen]
print(sum)


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


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


n = eval(input())
m = input().split()
A = 0
max = 0
for i in m:
	A = A + eval(i)
	if eval(i) > max:
		max = eval(i)
S = max * n
s = S - A
print(s)


n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
count = 0
for i in range(1, n):
	if n == 1:
		break
	elif a[i] == a[0]:
		continue
	else:
		count += abs(a[i] - a[0])
print(count)


input()
c = [int(i) for i in input().split(' ')]
t = max(c)
a = 0
for i in c:
	a += t - i
print(a)


n = int(input())
s = input().split()
lst = list()
for i in range(n):
	lst.append(int(s[i]))
m = max(lst)
tot = 0
for i in range(n):
	tot = tot + (m - int(s[i]))
print(tot)


n = int(input())
n_list = [int(x) for x in input().split()]
length = len(n_list)
n_list = sorted(n_list)
(counter, total) = (0, 0)
while counter < length:
	total += max(n_list) - n_list[counter]
	counter += 1
print(total)


num = int(input())
mylist = list(map(int, input().split(None, num)[:num]))
welfare = 0
for i in range(num):
	welfare += max(mylist) - mylist[i]
print(welfare)


f = lambda : map(int, input().split())
f()
b = list(f())
print(sum((max(b) - i for i in b)))


n = int(input())
c = input().split()
tot = 0
for i in range(0, len(c)):
	c[i] = int(c[i])
y = max(c)
for i in range(0, len(c)):
	tot += y - c[i]
print(tot)


n = int(input())
lista = list(map(int, input().split()))
M = max(lista)
c = 0
for i in range(n):
	c = c + M - lista[i]
print(c)


n = input().split()
c = [int(x) for x in input().split()]
max = 0
b = 0
temp = 0
for i in range(len(c)):
	if c[i] >= max:
		max = c[i]
for j in range(len(c)):
	temp = max - c[j]
	b = b + temp
print(b)


n = input()
ls = list(map(int, input().split()))
print(sum((max(ls) - l for l in ls)))


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


n = int(input())
welfare = list(map(int, input().split()))
ans = 0
welfare.sort()
for x in range(n - 1):
	ans += welfare[n - 1] - welfare[x]
print(ans)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	n = I()
	a = LI()
	return max(a) * n - sum(a)
print(main())


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


n = int(input())
welfares = list(map(int, input().split()))
welfares.sort()
cost = welfares[-1]
money = 0
for i in welfares:
	money += cost - i
print(money)


n = int(input())
lt = list(map(int, input().split()))
maxlt = max(lt)
cost = 0
for i in lt:
	if i != maxlt:
		cost += maxlt - i
print(cost)


def recurse(A, maxim):
	if len(A) > 1:
		return maxim - A[0] + recurse(A[1:], maxim)
	else:
		return maxim - A[0]
n = int(input())
A = list(map(int, input().split()))
maximum = max(A)
print(recurse(A, maximum))


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
m = arr[-1]
sum = 0
for i in arr:
	sum += m - i
print(sum)


def income_equality(citizen):
	count = 0
	max_income = max(citizen)
	for value in citizen:
		if value < max_income:
			count += max_income - value
	return count
number_of_citizen = int(input())
income_distrib = list(map(int, input().split()))
print(income_equality(income_distrib))


i = input
n = int(i())
l = [*map(int, input().split())]
Max = max(l)
Cost = 0
for j in l:
	Cost += Max - j
print(Cost)


n = int(input())
lst = list(map(int, input().strip().split()))[:n]
x = max(lst)
val = 0
for i in lst:
	val += x - i
print(val)


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


a = int(input())
b = [int(x) for x in input().split()]
count = 0
for i in b:
	count = count + max(b) - i
print(count)


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


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


n = int(input())
z = [int(i) for i in input().split()]
liste = []
z.sort(reverse=1)
for i in range(n):
	a = z[0] - z[i]
	liste.append(a)
print(sum(liste))


n = int(input())
A = [int(c) for c in input().split()]
ans = 0
_max = max(A)
for a in A:
	ans += _max - a
print(ans)


import os
import sys
from io import BytesIO, IOBase
import math

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(int(n))
	return l

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)

def countcon(s, i):
	c = 0
	ch = s[i]
	for i in range(i, len(s)):
		if s[i] == ch:
			c += 1
		else:
			break
	return c
n = int(input())
l = list(map(int, input().split()))
a = 0
ma = max(l)
for i in l:
	a += abs(ma - i)
print(a)


n = int(input())
l = list(map(int, input().strip().split()))
a = max(l)
count = 0
for i in l:
	b = a - i
	count = count + b
print(count)


n = int(input())
a = list(map(int, input().split()))
m = max(a)
count = 0
for i in a:
	if i < m:
		count += m - i
print(count)


a = int(input())
b = [int(x) for x in input().split()]
c = max(b)
s = 0
for i in b:
	s += abs(c - i)
print(s)


n = int(input())
c = list(map(int, input().split(' ')))
e = sorted(c)
total = 0
for x in e[:n]:
	total += e[n - 1] - x
print(total)


N = int(input())
L = list(map(int, input().split()))
A = max(L)
print(sum(list(map(lambda x: A - x, L))))


n = int(input())
x = input().split()
if n == 1:
	print(0)
else:
	z = 0
	for i in range(n):
		x[i] = int(x[i])
	m = max(x)
	for i in range(n):
		z += m - x[i]
	print(z)


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	alst = list(map(int, input().split()))
	max_ = max(alst)
	print(max_ * n - sum(alst))
main()


n = int(input())
v = [n for n in input().split()]
mayor = 0
sum = 0
for it in v:
	x = int(it)
	if x > mayor:
		mayor = x
for it in v:
	x = int(it)
	sum = sum + (mayor - x)
print(sum)


n = int(input())
a = list(map(int, input().split()))
a.sort()
max_welfare = a[a.__len__() - 1]
charge = 0
for i in range(a.index(max_welfare)):
	charge += max_welfare - a[i]
print(charge)


n = int(input())
l = [int(i) for i in input().split(' ')]
m = max(l)
c = 0
for e in l:
	if e < m:
		c += m - e
print(c)


n = int(input())
res = 0
a = list(map(int, input().split()))
a.sort()
m = a[n - 1]
for i in range(n - 1):
	res += abs(m - a[i])
print(res)


n = int(input())
l = list(map(int, input().split()))
k = max(l)
m = [abs(i - k) for i in l]
print(sum(m))


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


n = int(input(''))
l1 = list(map(int, input('').split(' ')))
k = max(l1)
l2 = []
for i in range(len(l1)):
	m = k - l1[i]
	l2.append(m)
print(sum(l2))


n = int(input())
wealth = input().split()
wealth = [int(x) for x in wealth]
high = max(wealth)
burles = 0
for i in wealth:
	if high - i > 0:
		burles += high - i
print(burles)


n = int(input())
a = [int(s) for s in input().split()]
a.sort()
max = a[-1]
counter = 0
for i in range(n):
	if a[i] < max:
		counter += max - a[i]
print(counter)


N = int(input())
A = list(map(int, input().split()))
A.sort()
sum = 0
for i in range(0, N):
	sum += A[-1] - A[i]
print(sum)


n = int(input())
l = [int(x) for x in input().split()]
m = max(l)
money = 0
for i in l:
	if i == m:
		continue
	elif i < m:
		money += m - i
print(money)


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


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


n = int(input())
lst = list((int(num) for num in input().split()))[:n]
max1 = max(lst)
burles = 0
for i in range(0, len(lst)):
	if lst[i] != max:
		burles += max1 - lst[i]
print(burles)


t = int(input())
welfares = [int(i) for i in input().split()]
max_welfares = max(welfares)
result = 0
for wel in welfares:
	result += max_welfares - wel
print(result)


n = int(input())
p = [int(x) for x in input().split()]
m = max(p)
counter = 0
for i in p:
	if i < m:
		counter = counter + m - i
print(counter)


lngth = int(input())
lst = list(map(int, input().split()))
maxm = max(lst)
res = 0
if lngth == 1:
	print(0)
else:
	for i in range(lngth):
		res += maxm - lst[i]
	print(res)


n = int(input())
output = []
arr = list(map(int, input().split()))
max_burle = max(arr)
need_burle = 0
i = 0
while i < n:
	if arr[i] < max_burle:
		need_burle += max_burle - arr[i]
	i += 1
output.append(need_burle)
for i in output:
	print(i)


n = int(input())
j = input().split()
l = len(j)
i = 0
while i < l:
	j[i] = int(j[i])
	i = i + 1
maxi = max(j)
sum = 0
for f in j:
	a = maxi - f
	sum = sum + a
print(sum)


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


from sys import stdin, stdout
n = int(stdin.readline())
arr = [int(i) for i in stdin.readline().split()]
m = max(arr)
ans = 0
for i in arr:
	ans += m - i
stdout.write(str(ans))


n = int(input())
A = list(map(int, input().split()))
mx = max(A)
sol = 0
for el in A:
	sol += abs(mx - el)
print(sol)


t = input()
a = [int(i) for i in input().split()]
a.sort()
maxxx = a[-1]
wyn = 0
for q in a:
	wyn += maxxx - q
print(wyn)


t = int(input())
p = list(map(int, input().split()))
k = max(p)
s = 0
for i in range(t):
	s += k - p[i]
print(s)


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


n = int(input())
k = [int(i) for i in input().split()]
k = sorted(k)
d = 0
for i in range(n):
	if k[i] < k[-1]:
		d += k[-1] - k[i]
	elif k[i] == k[-1]:
		break
print(d)


n = int(input())
mas = [int(i) for i in input().split()]
vmax = max(mas)
vsum = 0
for i in mas:
	vsum += vmax - i
print(vsum)


n = int(input())
T = list(map(int, input().split()))
t = T[0]
for i in range(n):
	if t < T[i]:
		t = T[i]
	else:
		t = t
S = 0
for i in range(n):
	S += t - T[i]
print(S)


people = int(input())
welfare = [int(v) for v in input().split()]
print(max(welfare) * people - sum(welfare))


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


from array import *
n = int(input())
(*s,) = map(int, input().split())
print(n * max(s) - sum(s))


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


n = int(input())
entrada = str(input())
entrada = entrada.split()
welfare = [int(x) for x in entrada]
equality_number = max(welfare)
suma = 0
for x in welfare:
	suma += equality_number - x
print(suma)


def holidayOfEquality():
	n = int(input())
	values = input().split()
	sum = 0
	values = [int(i) for i in values]
	maxValue = max(values)
	for i in range(len(values)):
		sum += maxValue - int(values[i])
	print(sum)
holidayOfEquality()


n = int(input())
spending = 0
welfares = input().split(' ')
for i in range(len(welfares)):
	welfares[i] = int(welfares[i])
maxVal = 0
for i in range(len(welfares)):
	if welfares[i] > maxVal:
		maxVal = welfares[i]
for i in range(len(welfares)):
	if welfares[i] < maxVal:
		spending += maxVal - welfares[i]
print(spending)


def main():
	(n, l) = (int(input()), list(map(int, input().split())))
	print(n * max(l) - sum(l))
main()


n = int(input())
lists = list(map(int, input().split()))[:n]
bur = 0
akhir = sorted(lists)
for i in akhir:
	bur = bur + (akhir[n - 1] - i)
print(bur)


line1 = int(input())
line2 = input().split()
m = []
for i in line2:
	m.append(int(i))
n = max(m)
s = 0
for i in range(line1):
	s = int(s) + (n - m[i])
print(s)


n = int(input())
a = list(map(int, input().split()))
i = 0
c = 0
if n > 1:
	ma = max(a)
	while i < n:
		c = c + ma - a[i]
		i = i + 1
	print(c)
else:
	print(0)


a = input()
b = list(map(int, input().split()))
c = max(b)
d = 0
for i in range(b.count(max(b))):
	b.remove(max(b))
if len(b) == 0:
	print(0)
else:
	for i in b:
		d += abs(c - i)
	print(d)


import random
import sys
import os

def mergeSort(alist):
	if len(alist) > 1:
		mid = len(alist) // 2
		lefthalf = alist[:mid]
		righthalf = alist[mid:]
		mergeSort(lefthalf)
		mergeSort(righthalf)
		i = 0
		j = 0
		k = 0
		while i < len(lefthalf) and j < len(righthalf):
			if lefthalf[i] < righthalf[j]:
				alist[k] = lefthalf[i]
				i = i + 1
			else:
				alist[k] = righthalf[j]
				j = j + 1
			k = k + 1
		while i < len(lefthalf):
			alist[k] = lefthalf[i]
			i = i + 1
			k = k + 1
		while j < len(righthalf):
			alist[k] = righthalf[j]
			j = j + 1
			k = k + 1
n = int(input())
arr = [int(x) for x in input().split()]
mergeSort(arr)
sum = 0
for x in range(0, n):
	sum += arr[n - 1] - arr[x]
print(sum)


n = int(input())
l = list(input().split())
li = []
for i in l:
	li.append(int(i))
s = 0
m = max(li)
for i in li:
	d = m - i
	s += d
print(s)