#include <bits/stdc++.h>
using namespace std;
const long long inf = (long long)1e+9 + 7ll;
const long long linf = (long long)1e+18 + 7ll;
const long double eps = (long double)1e-10;
const long double pi = acosl((long double)-1.0);
const int alph = 26;
static char buff[(int)2e6 + 17];
const int maxn = (int)1e6 + 17;
int nn;
int b[maxn];
struct segtree {
  vector<pair<int, int> > T;
  segtree(int n) { nn = n, T.resize(4 * n); }
  segtree() {}
  pair<int, int> build(int v = 1, int l = 0, int r = nn - 1) {
    if (l == r) return T[v] = make_pair(b[l], l);
    int m = (l + r) / 2;
    return T[v] = max(build(2 * v, l, m), build(2 * v + 1, m + 1, r));
  }
  void upd(int i, int v = 1, int l = 0, int r = nn - 1) {
    if (l == r)
      T[v] = make_pair(-1, l);
    else {
      int m = (l + r) / 2;
      i <= m ? upd(i, 2 * v, l, m) : upd(i, 2 * v + 1, m + 1, r);
      T[v] = max(T[2 * v], T[2 * v + 1]);
    }
  }
  pair<int, int> get(int lq, int rq, int v = 1, int l = 0, int r = nn - 1) {
    if (r < lq || l > rq) return make_pair(-1, l);
    if (lq <= l && r <= rq) return T[v];
    int m = (l + r) / 2;
    return max(get(lq, rq, 2 * v, l, m), get(lq, rq, 2 * v + 1, m + 1, r));
  }
};
int n;
int a[maxn], c[maxn], ans[maxn];
bool used[maxn];
segtree T;
vector<int> res;
bool read() {
  if (scanf("%d", &n) != 1) return false;
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  return true;
}
void check() {
  memset(used, false, sizeof(used));
  memset(c, -1, sizeof(c));
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      if (!used[j] && ans[j] > ans[i]) {
        used[j] = true;
        c[i] = j + 1;
        break;
      }
  for (int i = 0; i < n; ++i) printf("%d ", c[i]);
  printf("\n");
}
void dfs(int v) {
  used[v] = true;
  T.upd(v);
  if (b[v] != n && !used[b[v]]) dfs(b[v]);
  for (;;) {
    auto p = T.get(0, a[v] - 1);
    if (p.first > v)
      dfs(p.second);
    else
      break;
  }
  res.push_back(v);
}
void solve() {
  fill(b, b + n, n);
  T = segtree(n);
  for (int i = 0; i < n; ++i) {
    a[i] == -1 ? a[i] = n : --a[i];
    if (a[i] != n) b[a[i]] = i;
  }
  T.build();
  for (int i = 0; i < n; ++i)
    if (!used[i]) dfs(i);
  for (int i = 0; i < n; ++i) ans[res[i]] = i + 1;
  for (int i = 0; i < n; ++i) printf("%d ", ans[i]);
}
void gen() {}
void naive() {}
int main() {
  if (1) {
    while (read()) solve();
  } else {
    for (;;) {
      gen();
      solve();
      naive();
    }
  }
  return 0;
}
