#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 5;
int a[maxn], b[maxn];
int val[maxn], tim, n;
int mx[maxn << 2], sum[maxn << 2];
void up(int t) {
  mx[t] = max(mx[t << 1], mx[t << 1 | 1]);
  sum[t] = sum[t << 1] + sum[t << 1 | 1];
}
void build(int l, int r, int t) {
  if (l == r) {
    mx[t] = b[l];
    sum[t] = 1;
    return;
  }
  int mid = (l + r) >> 1;
  build(l, mid, t << 1);
  build(mid + 1, r, t << 1 | 1);
  up(t);
}
void del(int l, int r, int x, int t) {
  if (l == r) {
    --sum[t];
    mx[t] = 0;
    return;
  }
  int mid = (l + r) >> 1;
  if (x <= mid)
    del(l, mid, x, t << 1);
  else
    del(mid + 1, r, x, t << 1 | 1);
  up(t);
}
int solve(int ll, int rr, int l, int r, int x, int t) {
  if (!sum[t] || mx[t] <= x || ll > rr) return -1;
  if (l == r) return l;
  int mid = (l + r) >> 1;
  int ans = -1;
  if (ll <= mid) ans = max(ans, solve(ll, rr, l, mid, x, t << 1));
  if (ans == -1 && rr > mid)
    ans = max(ans, solve(ll, rr, mid + 1, r, x, t << 1 | 1));
  return ans;
}
void dfs(int u) {
  if (!val[b[u]] && b[u] <= n) dfs(b[u]);
  int lst = 0;
  while (1) {
    int v = solve(lst + 1, a[u] - 1, 1, n, u, 1);
    if (v == -1) break;
    lst = v;
    if (v != u) dfs(v);
  }
  val[u] = ++tim;
  del(1, n, u, 1);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> 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;
  build(1, n, 1);
  for (int i = 1; i <= n; ++i)
    if (!val[i]) dfs(i);
  for (int i = 1; i <= n; ++i) cout << val[i] << ' ';
  return 0;
}
