#include <iostream>
#include <vector>
using namespace std;

void solve() {
	int nn;
	cin >> nn;
	vector<int> dane(nn);
	for(int i=0; i<nn; i++) {
		cin >> dane[i];
		if(dane[i] > i) {
			cout << "NIE\n";
			return;
		}
	}
	vector<vector<int>> agr;
	int n = nn;
	int val = 1;
	while(n>1) {
		agr.push_back(vector<int>(n, val));
		n = (n+1)/2;
		val *= 2;
	}
	vector<int> odp(nn, 0);
	for(int i=nn-1; i>=0; i--) {
		val = i - dane[i] + 1;
		int pos = 0;
		for(int ia = agr.size()-1; ia>=0; ia--) {
			vector<int> &a = agr[ia];
			if(a[pos]<val) {
				val -= a[pos];
				pos += 1;
			}
			a[pos] -= 1;
			pos *= 2;
		}
		odp[i] = pos/2+1;
	}
	int cnt = 0;
	for(int i : odp) {
		if (cnt == odp.size() - 1)
			cout << i << "\n";
		else
			cout << i << " ";
		cnt++;
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	solve();
}
