#include <bits/stdc++.h>
using namespace std;
int n, a[500005], b[500005];
int vis[500005], ans[500005], cnt;
struct segment {
  int l, r;
  pair<int, int> tp;
} tr[500005 << 2];
void build(int i, int l, int r) {
  tr[i].l = l, tr[i].r = r;
  if (l == r) {
    tr[i].tp = make_pair(b[l], l);
    return;
  }
  int mid = (l + r) >> 1;
  build(i << 1, l, mid);
  build(i << 1 | 1, mid + 1, r);
  tr[i].tp = max(tr[i << 1].tp, tr[i << 1 | 1].tp);
}
pair<int, int> query(int i, int l, int r) {
  if (l > r) return make_pair(0, 0);
  if (l <= tr[i].l && tr[i].r <= r) return tr[i].tp;
  pair<int, int> ret = make_pair(0, 0);
  int mid = (tr[i].l + tr[i].r) >> 1;
  if (l <= mid) ret = max(ret, query(i << 1, l, r));
  if (mid < r) ret = max(ret, query(i << 1 | 1, l, r));
  return ret;
}
void change(int i, int l) {
  if (tr[i].l == tr[i].r) {
    tr[i].tp = make_pair(0, tr[i].l);
    return;
  }
  int mid = (tr[i].l + tr[i].r) >> 1;
  if (l <= mid)
    change(i << 1, l);
  else
    change(i << 1 | 1, l);
  tr[i].tp = max(tr[i << 1].tp, tr[i << 1 | 1].tp);
}
void dfs(int now) {
  vis[now] = 1;
  change(1, now);
  if (b[now] != n + 1 && !vis[b[now]]) dfs(b[now]);
  while (1) {
    pair<int, int> tmp = query(1, 1, a[now] - 1);
    if (tmp.first > now)
      dfs(tmp.second);
    else
      break;
  }
  ans[now] = ++cnt;
}
int main() {
  scanf("%d", &n);
  for (register int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] == -1)
      a[i] = n + 1;
    else
      b[a[i]] = i;
  }
  for (register int i = 1; i <= n; i++)
    if (b[i] == 0) b[i] = n + 1;
  build(1, 1, n);
  for (register int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i);
  for (register int i = 1; i <= n; i++) printf("%d ", ans[i]);
}
