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:

import java.io.PrintWriter;
import java.util.*;
public class MikePermutation {
    static int n;
    // first number that is bigger that this element and was not used yet
    // -1 if there is no elements, that bigger
    static int a[];
    // time when this element was used
    // time n if the element was not used
    // -1 if already used in topological sort
    static int b[];
    static int permutation[];
    static SegmentMaxTree tree;
    static boolean used[];
    static int curNumber = 1;
    
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        n = s.nextInt();
        a = new int[n];
        // Time when number is used
        // b[i] = j if a[j] = i or -1 if there is no such j
        b = new int[n];
        Arrays.fill(b, n);
        permutation = new int[n];
        used = new boolean[n];
        for(int i = 0; i < n; ++i) {
            int j = s.nextInt() - 1;
            if(j != -2) {
                a[i] = j;
                b[j] = i;
            } else {
                a[i] = n-1;
            }
        }
        
        
        //System.out.println(Arrays.toString(b));
        tree = new SegmentMaxTree();
        //System.out.println(Arrays.toString(tree.tree));
//        tree.setVal(2,-1);
//        tree.setVal(0, -1);
//        System.out.println(tree.max(0, 1));
        for(int i = 0; i < n; ++i) {
            if(!used[i]) {
                topologicalSort(i);
            }
        }
        //System.out.println(Arrays.toString(permutation));
        for(int i = 0; i < n-1; ++i) {
            System.out.print(permutation[i] + " ");
        }
        System.out.println(permutation[n-1]);
    }
    
    /**
     * Topological sorting on graph G
     * edge (x,y) in G if and only if there is one of following conditions
     * 1.b[x] = y
     * 2.if a[x] = z, then all y such that y < z && y != x && b[y] > x 
     * @param v
     */
    
    static void topologicalSort(int x) {
        //System.out.println(x);
        used[x] = true;
        if(b[x] >= 0 && b[x] < n && !used[b[x]]) {
            topologicalSort(b[x]);
        }
        tree.setVal(x, -1);
        if(a[x] > 0) {
            int y = tree.max(0, a[x]);
            while(b[y] > x) {
                topologicalSort(y);
                y = tree.max(0, a[x]);
            }
        }
        permutation[x] = curNumber;
        curNumber++;
    }
    
    static class SegmentMaxTree {
        int tree[];
        int size;
        //version of array b where size is power of two
        int bCopy[];
        /**
         * constructs max segment tree of indexes from array b
         */
        SegmentMaxTree() {
            size = (int) Math.pow(2, Math.ceil(Math.log(n)/Math.log(2))); // The closest power of 2
            tree = new int[size*2];
            bCopy = new int[size];
            for(int i = 0; i < n; ++i) {
                bCopy[i] = b[i];
            }
            for(int i = n; i < size; ++i) {
                bCopy[i] = -1;
            }
            //leaves from size to size*2-1
            // ( from size + n to size*2 - 1 filled with "-1")
            for(int i = size; i < 2*size; ++i) {
                tree[i] = i-size;
            }
            //sequentially count maxes from tree[size-1] to tree[1]
            // ( tree[0] is not used)
            // left child of i is 2*i, right child is 2*i+1
            for(int i = size-1; i > 0; --i) {
                if(bCopy[tree[2*i]] >= bCopy[tree[2*i+1]]) {
                    tree[i] = tree[2*i];
                } else {
                    tree[i] = tree[2*i+1];
                }
            }
        }
        
        // returns one of index j from [start, end] such that b[j] is maximum on this segment
        // even indexes points to left children of their parents
        // odd indexes - to right parents
        int max(int start, int end) {
            int curMax = -2;
            int ans = 0;
            int left = start + size;
            int right = end + size;
            while(left <= right) {
                // if start is right child of its parent
                if(left%2 == 1) {
                    if(bCopy[tree[left]] > curMax) {
                        ans = tree[left];
                        curMax = bCopy[ans];
                    }
                    //ans = Integer.max(ans, tree[left]);
                }
                // if end is left child of its parent
                if(right%2 == 0) {
                    if(bCopy[tree[right]] > curMax) {
                        ans = tree[right];
                        curMax = bCopy[ans];
                    }
                    //ans = Integer.max(ans, tree[right]);
                }
                left = (left+1)/2;
                right = (right-1)/2;
            }
            return ans;
        }
        //sets b[x] to value and updates tree
        //parent of i is i/2
        void setVal(int x, int value) {
            b[x] = value;
            bCopy[x] = value;
            for(int i = (x+size)/2; i > 0; i /= 2) {
                if(bCopy[tree[2*i]] >= bCopy[tree[2*i+1]]) {
                    tree[i] = tree[2*i];
                } else {
                    tree[i] = tree[2*i+1];
                }
            }
        }
    }
}