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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const long long LINF = (long long)1e18;
const long double PI = acos((long double)-1);
const long double EPS = 1e-9;
inline long long gcd(long long a, long long b) {
  long long r;
  while (b) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
inline long long fpow(long long n, long long k, int p = MOD) {
  long long r = 1;
  for (; k; k >>= 1) {
    if (k & 1) r = r * n % p;
    n = n * n % p;
  }
  return r;
}
template <class T>
inline int chkmin(T& a, const T& val) {
  return val < a ? a = val, 1 : 0;
}
template <class T>
inline int chkmax(T& a, const T& val) {
  return a < val ? a = val, 1 : 0;
}
inline long long isqrt(long long k) {
  long long r = sqrt(k) + 1;
  while (r * r > k) r--;
  return r;
}
inline long long icbrt(long long k) {
  long long r = cbrt(k) + 1;
  while (r * r * r > k) r--;
  return r;
}
inline void addmod(int& a, int val, int p = MOD) {
  if ((a = (a + val)) >= p) a -= p;
}
inline void submod(int& a, int val, int p = MOD) {
  if ((a = (a - val)) < 0) a += p;
}
inline int mult(int a, int b, int p = MOD) { return (long long)a * b % p; }
inline int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }
inline int sign(long double x) { return x < -EPS ? -1 : x > +EPS; }
inline int sign(long double x, long double y) { return sign(x - y); }
const int maxn = 5e5 + 5;
int n;
int a[maxn];
int b[maxn];
vector<int> adj[maxn];
int ans[maxn];
int vis[maxn];
vector<int> ver;
pair<int, int> st[maxn << 1];
void upd(int p, int val) {
  int q = p;
  for (st[p += n] = make_pair(val, q); p > 1;)
    p >>= 1, st[p] = max(st[p << 1], st[p << 1 | 1]);
}
pair<int, int> query(int l, int r) {
  pair<int, int> res = make_pair(-1, -1);
  for (l += n, r += n + 1; l < r; l >>= 1, r >>= 1) {
    if (l & 1) chkmax(res, st[l++]);
    if (r & 1) chkmax(res, st[--r]);
  }
  return res;
}
void dfs(int u) {
  vis[u] = 1;
  upd(u, -1);
  for (int i = (0); i < (int((adj[u]).size())); i++) {
    int v = adj[u][i];
    if (!vis[v]) {
      dfs(v);
    }
  }
  while (1) {
    if (a[u] == -1) a[u] = n;
    pair<int, int> mx = query(0, a[u] - 1);
    if (mx.first <= u) break;
    int v = mx.second;
    if (!vis[v]) {
      dfs(v);
    }
  }
  ver.push_back(u);
}
void solve() {
  cin >> n;
  fill_n(b, n, n);
  for (int i = (0); i < (n); i++) {
    cin >> a[i];
    if (a[i] > 0) {
      a[i]--;
      b[a[i]] = i;
      adj[a[i]].push_back(i);
    }
  }
  for (int i = (0); i < (n); i++) upd(i, b[i]);
  for (int i = (0); i < (n); i++)
    if (!vis[i]) dfs(i);
  for (int i = (0); i < (int((ver).size())); i++) ans[ver[i]] = i;
  for (int i = (0); i < (n); i++) cout << ans[i] + 1 << " \n"[i == n - 1];
}
int main() {
  int JUDGE_ONLINE = 1;
  if (fopen("in.txt", "r")) {
    JUDGE_ONLINE = 0;
    assert(freopen("in.txt", "r", stdin));
  } else {
    ios_base::sync_with_stdio(0), cin.tie(0);
  }
  solve();
  if (!JUDGE_ONLINE) {
  }
  return 0;
}