# 10.03.2020 @odnaks
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)

7a92f7072f6b5ce618cceabeaa6d4c02a239054e
<mask token>

<mask token>
for i in range(n):
    if int(arr[i]) > max:
        max = int(arr[i])
<mask token>
for i in range(n):
    sum = sum + (max - int(arr[i]))
print(sum)

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)

# 10.03.2020 @odnaks
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)
