#include <bits/stdc++.h>
using std::make_pair;
using std::pair;
const int N = 500005;
pair<int, int> t[N << 2];
int n, a[N], b[N], vis[N], st[N], p[N], tp, cnt;
void build(int k, int l, int r) {
  if (l == r) {
    t[k] = make_pair(b[l], l);
    return;
  }
  int mid = (l + r) >> 1;
  build(k << 1, l, mid);
  build(k << 1 | 1, mid + 1, r);
  t[k] = max(t[k << 1], t[k << 1 | 1]);
}
void del(int k, int l, int r, int x) {
  if (l == r) {
    t[k] = make_pair(0, x);
    return;
  }
  int mid = (l + r) >> 1;
  if (x <= mid)
    del(k << 1, l, mid, x);
  else
    del(k << 1 | 1, mid + 1, r, x);
  t[k] = max(t[k << 1], t[k << 1 | 1]);
}
pair<int, int> query(int k, int L, int R, int l, int r) {
  if (r < l) return make_pair(0, 0);
  if (l == L && R == r) return t[k];
  int mid = (L + R) >> 1;
  if (r <= mid) return query(k << 1, L, mid, l, r);
  if (l > mid) return query(k << 1 | 1, mid + 1, R, l, r);
  return max(query(k << 1, L, mid, l, mid),
             query(k << 1 | 1, mid + 1, R, mid + 1, r));
}
void dfs(int x) {
  del(1, 1, n, x);
  vis[x] = 1;
  if (!vis[b[x]]) dfs(b[x]);
  while (1) {
    pair<int, int> tt = query(1, 1, n, 1, a[x] - 1);
    if (tt.first > x)
      dfs(tt.second);
    else
      break;
  }
  st[++tp] = 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;
    b[a[i]] = i;
  }
  for (int i = 1; i <= n; i++)
    if (!b[i]) b[i] = n + 1;
  vis[n + 1] = 1;
  build(1, 1, n);
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i);
  for (int i = 1; i <= n; i++) p[st[i]] = ++cnt;
  for (int i = 1; i <= n; i++) printf("%d ", p[i]);
}
