n = int(input())
arr = list(map(lambda x: int(x), input().split()))
arr.reverse()
m = arr[0]
arr[0] = 0
for i in range(1,n):
if arr[i]<=m:
arr[i] = m - arr[i] + 1
else:
m = arr[i]
arr[i]=0
arr.reverse()
for i in range(n):
print(arr[i], end = " ")
print(" ")
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,temp;
cin>>n;
int a[n],b[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
int max=0;
for(int i=n-1;i>=0;i--)
{
if(a[i]>max)
{
b[i]=0;
max=a[i];
}
else if(a[i]==max)
b[i]=1;
else
b[i]=max-a[i]+1;
}
for(int i=0;i<n;i++)
cout<<b[i]<<" ";
cout<<endl;
}
676B - Pyramid of Glasses | 597A - Divisibility |
1632A - ABC | 1619D - New Year's Problem |
242B - Big Segment | 938A - Word Correction |
159C - String Manipulation 10 | 258A - Little Elephant and Bits |
1536C - Diluc and Kaeya | 1428C - ABBB |
1557A - Ezzat and Two Subsequences | 255A - Greg's Workout |
1059A - Cashier | 1389C - Good String |
1561A - Simply Strange Sort | 1337B - Kana and Dragon Quest game |
137C - History | 1443C - The Delivery Dilemma |
6C - Alice Bob and Chocolate | 1077C - Good Array |
285B - Find Marble | 6A - Triangle |
1729A - Two Elevators | 1729B - Decode String |
1729C - Jumping on Tiles | 1729E - Guess the Cycle Size |
553B - Kyoya and Permutation | 1729D - Friends and the Restaurant |
1606C - Banknotes | 580C - Kefa and Park |