N = int(input())
A = list(map(int,input().split()))

keep = 0
cnt =0
x=0


for a in A:
    if keep > a:
        cnt += keep -a
        x = keep -a
        print(x)
        keep = a + x
    else:
      keep = a
    
    
print(cnt)