N persons are standing in a row. The height of the i-th person from the front is A_i.  We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:  Condition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool.  Find the minimum total height of the stools needed to meet this goal.
n=int(input())
a=list(map(int,input().split()))
s=0
for i in range(1,n):
  s+=max(0,a[i-1]-a[i])
print(s)
n=int(input())
a=list(map(int,input().split()))
s=0
m=a[0]
for i in range(1,n):
    if(a[i]>m):
        m=a[i]
    else:
        s+=(m-a[i])
print(s)