N = int(input())
A = list(map(int, input().split()))
pre = A[0]
ans = 0
if N == 1:
    print(0)
else:
    for a in A[1:]:
        print(ans)
        if pre > a:
            ans += pre - a
        else:
            pre = a
    print(ans)