Problem: Mike has discovered a new way to encode permutations. If he has a permutation P = [p1, p2, ..., pn], he will encode it in the following way:

Denote by A = [a1, a2, ..., an] a sequence of length n which will represent the code of the permutation. For each i from 1 to n sequentially, he will choose the smallest unmarked j (1 ≤ j ≤ n) such that pi < pj and will assign to ai the number j (in other words he performs ai = j) and will mark j. If there is no such j, he'll assign to ai the number  - 1 (he performs ai = - 1). 

Mike forgot his original permutation but he remembers its code. Your task is simple: find any permutation such that its code is the same as the code of Mike's original permutation.

You may assume that there will always be at least one valid permutation.

Input

The first line contains single integer n (1 ≤ n ≤ 500 000) — length of permutation.

The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ n or ai = - 1) — the code of Mike's permutation.

You may assume that all positive values from A are different.

Output

In first and only line print n numbers p1, p2, ..., pn (1 ≤ pi ≤ n) — a permutation P which has the same code as the given one. Note that numbers in permutation are distinct.

Examples

Input

6
2 -1 1 5 -1 4


Output

2 6 1 4 5 3


Input

8
2 -1 4 -1 6 -1 8 -1


Output

1 8 2 7 3 6 4 5

Note

For the permutation from the first example:

i = 1, the smallest j is 2 because p2 = 6 > p1 = 2.

i = 2, there is no j because p2 = 6 is the greatest element in the permutation.

i = 3, the smallest j is 1 because p1 = 2 > p3 = 1.

i = 4, the smallest j is 5 (2 was already marked) because p5 = 5 > p4 = 4.

i = 5, there is no j because 2 is already marked.

i = 6, the smallest j is 4 because p4 = 4 > p6 = 3.

Solution (in JAVA):

Solution:
//package round410;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class E3 {
	InputStream is;
	PrintWriter out;
	String INPUT = "";
	
	void solve()
	{
		int n = ni();
		int[] a = na(n);
		int[] from = new int[30000000];
		int[] to = new int[30000000];
		int p = 0;
		boolean[] mark = new boolean[n];
		int H = Integer.highestOneBit(Math.max(n-1, 1))<<1;
		for(int v : a){
			if(v >= 1){
				mark[v-1] = true;
			}
		}
		int idgen = n;
		int[] ids = new int[2*H];
		Arrays.fill(ids, -1);
//		for(int i = 1;i < H+n;i++){
//			ids[i] = idgen++;
//		}
		for(int i = 0;i < n;i++){
			if(!mark[i]){
				if(ids[H+i] == -1)ids[H+i] = idgen++;
				from[p] = i; to[p] = ids[H+i]; p++;
			}
		}
		for(int i = H+n-1;i >= 2;i--){
			if(ids[i] == -1)continue;
			if(ids[i/2] == -1)ids[i/2] = idgen++;
			from[p] = ids[i]; to[p] = ids[i/2]; p++;
		}
		for(int i = n-1;i >= 0;i--){
			int r = a[i] == -1 ? n : a[i]-1;
			if(r < i){
				while(0 < r){
					int f = r&-r;
					
					if(ids[(H+r)/f-1] != -1){
						from[p] = ids[(H+r)/f-1]; to[p] = i; p++;
					}
					r -= f;
				}
			}else{
				int rr = i;
				while(0 < rr){
					int f = rr&-rr;
					if(ids[(H+rr)/f-1] != -1){
						from[p] = ids[(H+rr)/f-1]; to[p] = i; p++;
					}
					rr -= f;
				}
				int l = i+1;
				if(l < r){
					while(l != 0){
						int f = l&-l;
						if(l+f > r)break;
						if(ids[(H+l)/f] != -1){
							from[p] = ids[(H+l)/f]; to[p] = i; p++;
						}
						l += f;
					}
					while(l < r){
						int f = r&-r;
						if(ids[(H+r)/f-1] != -1){
							from[p] = ids[(H+r)/f-1]; to[p] = i; p++;
						}
						r -= f;
					}
				}
			}
			if(a[i] > 0){
				int w = a[i]-1;
				from[p] = i; to[p] = w; p++;
				ids[H+w] = w;//idgen++;
//				from[p] = w; to[p] = ids[H+w]; p++;
				for(int cur = H+w;cur > 1;cur>>>=1){
					int par = cur>>>1;
					int nid = idgen++;
					if(ids[par] != -1){
						from[p] = ids[par]; to[p] = nid; p++;
					}
					if(ids[cur] != -1){
						from[p] = ids[cur]; to[p] = nid; p++;
					}
					ids[par] = nid;
				}
			}
//			{
//				int[][] g = packD(idgen, from, to, p);
//				int[] ord = sortTopologically(g);
//				tr(g);
//				tr(ord);
//			}
		}
//		tr(idgen, p);
		int[][] g = packX(idgen, from, to, p);
		int[] ord = sortTopologically(g);
		int[] ans = new int[n];
		Arrays.fill(ans, -1);
		int gen = 0;
		for(int v : ord){
			if(v < n){
				ans[v] = gen++;
			}
		}
		for(int i = 0;i < n;i++){
			out.print(ans[i]+1 + " ");
		}
	}
	
	public static int[] sortTopologically(int[][] gs)
	{
		int[] g = gs[0], offset = gs[1];
		int n = offset.length-1;
		int[] ec = new int[n];
		for(int i = 0;i < g.length;i++){
			ec[g[i]]++;
		}
		int[] ret = new int[n];
		int q = 0;
		
		// sources
		for(int i = 0;i < n;i++){
			if(ec[i] == 0)ret[q++] = i;
		}
		
		for(int p = 0;p < q;p++){
			for(int i = offset[ret[p]];i < offset[ret[p]+1];i++){
				if(--ec[g[i]] == 0)ret[q++] = g[i];
			}
		}
		// loop
		for(int i = 0;i < n;i++){
			if(ec[i] > 0)return null;
		}
		return ret;
	}

	
	public static int[][] packX(int n, int[] from, int[] to, int sup)
	{
		int[] g = new int[sup];
		int[] p = new int[n];
		for(int i = 0;i < sup;i++)p[from[i]]++;
		int[] offset = new int[n+1];
		for(int i = 1;i <= n;i++){
			offset[i] = offset[i-1] + p[i-1];
		}
		for(int i = 0;i < sup;i++){
			g[offset[from[i]] + (--p[from[i]])] = to[i];
		}
		return new int[][]{g, offset};
	}

	
	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);
		
		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}
	
	public static void main(String[] args) throws Exception { new E3().run(); }
	
	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;
	
	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}
	
	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }
	
	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }
	
	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	
	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}
	
	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}
	
	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}
	
	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}
		
		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	
	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}
		
		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	
	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}