#include <bits/stdc++.h>
using namespace std;
const int maxn = 500005;
int a[maxn], b[maxn], T[maxn * 4], p[maxn], cnt, n;
int cmp(int x, int y) { return b[x] > b[y] ? x : y; }
void build(int l, int r, int jd) {
  if (l == r)
    T[jd] = l;
  else {
    int mid = l + r >> 1;
    build(l, mid, jd << 1), build(mid + 1, r, jd << 1 | 1);
    T[jd] = cmp(T[jd << 1], T[jd << 1 | 1]);
  }
}
void del(int l, int r, int p, int jd) {
  if (l == r)
    T[jd] = 0;
  else {
    int mid = l + r >> 1;
    if (p <= mid)
      del(l, mid, p, jd << 1);
    else
      del(mid + 1, r, p, jd << 1 | 1);
    T[jd] = cmp(T[jd << 1], T[jd << 1 | 1]);
  }
}
int query(int l, int r, int i, int j, int jd) {
  if (j < l || i > r) return 0;
  if (i <= l && r <= j) return T[jd];
  int mid = l + r >> 1;
  return cmp(query(l, mid, i, j, jd << 1),
             query(mid + 1, r, i, j, jd << 1 | 1));
}
bool vis[maxn];
void dfs(int now) {
  if (vis[now]) return;
  vis[now] = 1;
  del(1, n, now, 1);
  if (b[now] <= n) dfs(b[now]);
  for (;;) {
    int mx = query(1, n, 1, a[now] - 1, 1);
    if (b[mx] > now)
      dfs(mx);
    else
      break;
  }
  p[now] = ++cnt;
}
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++) dfs(i);
  for (int i = 1; i <= n; i++) printf("%d%c", p[i], i == n ? '\n' : ' ');
  return 0;
}
