#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int n; cin >> n;
vector<int> a(n);
for(int i=0;i<n;++i) {
cin >> a[i];
}
a[0]=0;
for(int i=1; i<n; ++i) {
if(a[i]>0) {
for(int j=i-1; j>0; --j) {
if(a[j]>0||a[j+1]==0) break;
else a[j]=a[j+1]-1;
}
}
}
for(int i=0; i<n; ++i) {
cout << a[i] << "\n";
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCS8vIHlvdXIgY29kZSBnb2VzIGhlcmUKICAgIGludCBuOyBjaW4gPj4gbjsKICAgIHZlY3RvcjxpbnQ+IGEobik7IAogICAgZm9yKGludCBpPTA7aTxuOysraSkgewogICAgICAgIGNpbiA+PiBhW2ldOwogICAgfQogICAgYVswXT0wOwogICAgZm9yKGludCBpPTE7IGk8bjsgKytpKSB7CiAgICAgICAgaWYoYVtpXT4wKSB7CiAgICAgICAgICAgIGZvcihpbnQgaj1pLTE7IGo+MDsgLS1qKSB7CiAgICAgICAgICAgICAgICBpZihhW2pdPjB8fGFbaisxXT09MCkgYnJlYWs7CiAgICAgICAgICAgICAgICBlbHNlIGFbal09YVtqKzFdLTE7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CiAgICBmb3IoaW50IGk9MDsgaTxuOyArK2kpIHsKICAgICAgICBjb3V0IDw8IGFbaV0gPDwgIlxuIjsKICAgIH0KCXJldHVybiAwOwp9