#include <bits/stdc++.h>
using namespace std;
pair<int, int> tree[2000000];
int e[600000], g[600000], h[600000];
bool b[600000];
int i, n, q;
inline void buildtree(int l, int r, int node) {
  if (l == r)
    if (h[l])
      tree[node] = make_pair(h[l], l);
    else
      tree[node] = make_pair(n + 1, l);
  else {
    int mid = (l + r) >> 1;
    buildtree(l, mid, node << 1);
    buildtree(mid + 1, r, node << 1 | 1);
    tree[node] = max(tree[node << 1], tree[node << 1 | 1]);
  }
  return;
}
inline void inserttree(int l, int r, int x, int node) {
  if (l == r)
    tree[node] = make_pair(0, l);
  else {
    int mid = (l + r) >> 1;
    if (x <= mid)
      inserttree(l, mid, x, node << 1);
    else
      inserttree(mid + 1, r, x, node << 1 | 1);
    tree[node] = max(tree[node << 1], tree[node << 1 | 1]);
  }
  return;
}
inline pair<int, int> asktree(int l, int r, int x, int y, int node) {
  if ((l == x) && (r == y)) return tree[node];
  int mid = (l + r) >> 1;
  if (y <= mid) return asktree(l, mid, x, y, node << 1);
  if (x > mid) return asktree(mid + 1, r, x, y, node << 1 | 1);
  return max(asktree(l, mid, x, mid, node << 1),
             asktree(mid + 1, r, mid + 1, y, node << 1 | 1));
}
inline void dfs(int x) {
  b[x] = true;
  inserttree(1, n, x, 1);
  if ((h[x]) && (!b[h[x]])) dfs(h[x]);
  pair<int, int> tmp;
  while ((g[x] > 1) && (tmp = asktree(1, n, 1, g[x] - 1, 1), tmp.first > x))
    dfs(tmp.second);
  q++, e[x] = q;
  return;
}
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &g[i]);
    if (g[i] != -1)
      h[g[i]] = i;
    else
      g[i] = n + 1;
  }
  buildtree(1, n, 1);
  for (i = 1; i <= n; i++)
    if (!b[i]) dfs(i);
  for (i = 1; i <= n; i++) printf("%d ", e[i]);
  return 0;
}
