The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.

Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all the houses with larger numbers. In other words, a house is luxurious if the number of floors in it is strictly greater than in all the houses, which are located to the right from it. In this task it is assumed that the heights of floors in the houses are the same.

The new architect is interested in n questions, i-th of them is about the following: "how many floors should be added to the i-th house to make it luxurious?" (for all i from 1 to n, inclusive). You need to help him cope with this task.

Note that all these questions are independent from each other — the answer to the question for house i does not affect other answers (i.e., the floors to the houses are not actually added).


-----Input-----

The first line of the input contains a single number n (1 ≤ n ≤ 10^5) — the number of houses in the capital of Berland.

The second line contains n space-separated positive integers h_{i} (1 ≤ h_{i} ≤ 10^9), where h_{i} equals the number of floors in the i-th house. 


-----Output-----

Print n integers a_1, a_2, ..., a_{n}, where number a_{i} is the number of floors that need to be added to the house number i to make it luxurious. If the house is already luxurious and nothing needs to be added to it, then a_{i} should be equal to zero.

All houses are numbered from left to right, starting from one.


-----Examples-----
Input
5
1 2 3 1 2

Output
3 2 0 2 0 
Input
4
3 2 1 4

Output
2 3 4 0

Difficulty: interview

Starter code:

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

print(*b)


import sys

def solve():
    n, = rv()
    h, = rl(1)
    maxsofar = 0
    res = [0] * n
    for i in range(n - 1, -1, -1):
        if h[i] <= maxsofar:
            res[i] = maxsofar - h[i] + 1
        else:
            maxsofar = h[i]
    prt(res)





def prt(l): return print(' '.join(map(str, l)))
def rs(): return map(str, input().split())
def rv(): return map(int, input().split())
def rl(n): return [list(map(int, input().split())) for _ in range(n)]  
if sys.hexversion == 50594544 : sys.stdin = open("test.txt")
solve()

import sys


#sys.stdin = open('input.txt')
#sys.stdout = open('output.txt', 'w')

n = int(input())
h = [int(i) for i in input().split()]
h = h[::-1]
ans = []
curmax = h[0] - 1
for i in range(n):
	if h[i] <= curmax:
		ans.append(curmax + 1 - h[i])
	else:
		ans.append(0)
	curmax = max(curmax, h[i])

ans = ans[::-1]
for x in ans:
	print(x, end = ' ')	


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

maxx = 0
ans = []
for h in reversed(hs):
    if h > maxx:
        ans.append(0)
    else:
        ans.append(maxx-h+1)
    maxx = max(maxx, h)

print(' '.join(map(str, reversed(ans))))

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

ans = []
m = 0
for i in range(n - 1, -1, -1):
    ans.append(max(0, (m + 1) - a[i]))
    m = max(m, a[i])

ans.reverse()
for i in ans:
    print(i, end = ' ')

n=int(input())
l=list(map(int,input().split()))
s=[0]*n
a=[0]*n
s[-1]=l[-1]
for i in range(1,n): 
    if l[n-i-1]<=s[n-i]: a[n-i-1]=s[n-i]-l[n-i-1]+1
    s[n-i-1]=max(l[n-i-1],s[n-i])
print(' '.join(map(str,a)))

n = int(input())
h = [int(i) for i in input().split()] + [0]
v = [0 for i in h]
for p in range(n,-1,-1):
    if p == n: v[p] = h[p]
    else: v[p] = max(v[p+1], h[p])
print(' '.join(["%s" % max(0, v[i+1]+1-h[i]) for i in range(n)]))

n = int(input())
h = tuple(map(int, str.split(input())))
hm = [0] * (n)

ch = 0
for i, x in enumerate(reversed(h)):

    hm[i] = max(0, ch - x + 1)
    ch = max(ch, x)

print(str.join(" ", list(map(str, reversed(hm)))))


#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import time

n   = int(input())
A   = [int(i) for i in input().split()]

start = time.time()

A   = [ A[n-i-1] for i in range(n)]
ans = [ 0 for i in range(n) ]

m   = 0
for i in range(n):
    if A[i] > m:
        m = A[i]
    else:
        ans[i] = 1+m-A[i]

for i in range(n):
    print(ans[n-1-i], end=' ')
print()
finish = time.time()
#print(finish - start)


n = int(input())
l = [int(x) for x in input().split()]
assert len(l) == n
l.reverse()
pre = [0]
for i in range(1, n):
    pre.append(max(pre[-1], l[i-1]))
out = [max(0, 1+pre[i]-l[i]) for i in range(n)]
out.reverse()
print(' '.join(str(x) for x in out))


n = int(input())
home = list(map(int, input().split()))
suff = [0] * n
for i in range(n - 2, -1, -1):
    suff[i] = max(suff[i + 1], home[i + 1])
for i in range(n):
    if home[i] > suff[i]:
        print(0, end=" ")
    else:
        print(suff[i] - home[i] + 1, end=" ")


n= int(input())
mas = list(map(int,input().split(" ")))
submas=[0]*(n)
ma=0
for i in range(n-1,-1,-1):
    submas[i]=str(max(ma-mas[i]+1,0))
    if (ma<mas[i]):
        ma =mas[i]

print(" ".join(submas))


n = list(map(int, input().split()))
a = list(map(int, input().split()))
a.reverse()
mx = a[0]
ans = list()
ans.append(0)
for i in a[1:]:
    ans.append(max(0, mx - i + 1))
    mx = max(mx, i)
ans.reverse()
p = ''
for i in ans:
    p += i.__str__() + ' '
print(p)



n=int(input())
arr=list(map(int,input().split()))
temp=[None]*n
m=0
last=0
for i in range(n):
    if last>m:
        m=last
    last=arr[n-1-i]
    temp[n-1-i]=m
for i in range(len(arr)):
    if arr[i]<temp[i]+1:
        print(temp[i]+1-arr[i],end=' ')
    else:
        print(0,end=' ')


t = int(input())

a = list(map(int , input().split()))
b=[]
max = a[t-1]
i=t-2
while i >= 0:
    if a[i] <= max:
        b.append(max-a[i]+1)
    else:
        max = a[i]
        b.append(0)
    i = i-1
b.insert( 0, "0")
i = t-1
while(i>=0):
    print(b[i] , end = " ")
    i = i-1

n = int(input())
h = list(map(int,input().split()))
a = []

if n==1:
    print(0)
    quit()
y = h[-1]
h[-1] = 0
for i in reversed(range(n-1)):
    if h[i]>y:
        y = max(h[i],y)
        h[i] = 0
        h[-1] = 0

    else:
        h[i] = (y-h[i]+1)
    """
tmp = h[-1]
for i in reversed(range(n-1)):
    if h[i]<=tmp:
        a.append(tmp-h[i]+1)
        tmp = max(tmp,h[i])
    else:a.append(0)"""
print(' '.join(map(str,(h))))

__author__ = 'User'
n = int(input())
arr = list(map(int, input().split()))
mx = [0] * (n + 1)
for i in range(n - 1, -1, -1):
    #print(arr[i], mx[i + 1])
    mx[i] = max(mx[i + 1], arr[i])
for j in range(n):
    if mx[j + 1] >= arr[j]:
        print(mx[j] - arr[j] + 1, end = " ")
    else:
        print(0, end = " ")

#-*- coding: utf-8 -*-

n = int(input())
houses = list(map(int, input().split()))
height = [0]
result = []

for i in range(n):
	if houses[n - i - 1] > height[i]:
		height.append(houses[n - i - 1])
		result.append(0)
	else:
		height.append(height[i])
		result.append(height[i] - houses[n - i - 1] + 1)

for i in range(n):
	print(result[n - i - 1], end=' ')

n = int(input())
lst = list(map(int, input().split()))
dp = [-1000] * n
dp[n - 1] = 0
for i in range(len(lst) - 2, -1, -1):
    dp[i] = max(dp[i + 1], lst[i + 1])
for i in range(n):
    if dp[i] >= lst[i]:
        print(dp[i] - lst[i] + 1, end=' ')
    else:
        print(0, end=' ')
        

           


input()
n, result = [int(x) for x in input().split()], []
max = -1

for i in range(len(n) - 1, -1, -1):
    if n[i] <= max:
        result.append(max - n[i] + 1)
    else:
        max = n[i]
        result.append(0)

for i in range(len(result) - 1, -1, -1):
    print(result[i], end = ' ')
print()

n = int(input())
a = [int(x) for x in input().split()]
m = [0 for x in range(n)]
m[n - 1] = a[n - 1]
for i in range(n - 2, -1, -1):
    m[i] = max(m[i + 1], a[i])
for i in range(n - 1):
    print(max(0, m[i + 1] + 1 - a[i]), end=" ")
print(0)

n = int(input()); li = list(map(int, input().split(" ")))
lu = []
k = 0
for i in range(n-1, -1, -1):
    lu.append(max(0, k+1-li[i]))
    k = max(k, li[i])
lu.reverse()
print(' '.join(map(str, lu)))


    

    
    


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


n = int(input())
a = list(map(int, input().split()))
b = [0] * n
ma = a[-1]
for i in range(n - 2, -1, -1):
    if a[i] <= ma:
        b[i] = ma - a[i] + 1
    else:
        ma = a[i]
print(*b)