#include <bits/stdc++.h>
using namespace std;
const int N = 500010;
int a[N], b[N], p[N], n, tid, ans[N];
pair<int, int> seg[N << 2];
bool did[N];
void build(int l, int r, int rt) {
  if (l == r) {
    seg[rt] = {b[l], l};
    return;
  }
  int m = l + r >> 1;
  build(l, m, rt << 1);
  build(m + 1, r, rt << 1 | 1);
  seg[rt] = max(seg[rt << 1], seg[rt << 1 | 1]);
}
void del(int pos, int l, int r, int rt) {
  if (l == r) {
    seg[rt] = {0, 0};
    return;
  }
  int m = l + r >> 1;
  if (pos <= m)
    del(pos, l, m, rt << 1);
  else
    del(pos, m + 1, r, rt << 1 | 1);
  seg[rt] = max(seg[rt << 1], seg[rt << 1 | 1]);
}
pair<int, int> query(int L, int R, int l, int r, int rt) {
  if (L <= l && R >= r) return seg[rt];
  int m = l + r >> 1;
  pair<int, int> ans = {0, 0};
  if (L <= m) ans = max(ans, query(L, R, l, m, rt << 1));
  if (R > m) ans = max(ans, query(L, R, m + 1, r, rt << 1 | 1));
  return ans;
}
void dfs(int x) {
  did[x] = true;
  del(x, 1, n, 1);
  if (b[x] != n + 1 && !did[b[x]]) dfs(b[x]);
  if (a[x] > 1) {
    while (1) {
      pair<int, int> t = query(1, a[x] - 1, 1, n, 1);
      if (t.first > x)
        dfs(t.second);
      else
        break;
    }
  }
  p[++tid] = x;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] == -1)
      a[i] = n + 1;
    else
      b[a[i]] = i;
  }
  for (int i = 1; i <= n; i++)
    if (!b[i]) b[i] = n + 1;
  build(1, n, 1);
  for (int i = 1; i <= n; i++)
    if (!did[i]) dfs(i);
  for (int i = 1; i <= n; i++) ans[p[i]] = i;
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
}
