#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 228;
int us[N], a[N], z[N], ans[N];
vector<int> tv[N * 4];
vector<int> path, g[N];
int n;
void add(int v, int l, int r, int i, int x) {
  tv[v].push_back(x);
  if (l == r) return;
  int c = (l + r) >> 1;
  if (i <= c)
    add(v << 1, l, c, i, x);
  else
    add((v << 1) ^ 1, c + 1, r, i, x);
}
void make(int v, int l, int r) {
  sort(tv[v].rbegin(), tv[v].rend());
  if (l == r) return;
  int c = (l + r) >> 1;
  make(v << 1, l, c);
  make((v << 1) ^ 1, c + 1, r);
}
int get(int ll, int rr, int l, int r, int v, int rk) {
  if (rr < l || r < ll) return -1;
  if (ll <= l && r <= rr) {
    while (tv[v].size() && us[tv[v].back()] && tv[v].back() <= rk)
      tv[v].pop_back();
    if (tv[v].size() == 0 || tv[v].back() > rk) return -1;
    return tv[v].back();
  }
  int c = (l + r) >> 1;
  int t = get(ll, rr, l, c, v << 1, rk);
  if (t != -1) return t;
  t = get(ll, rr, c + 1, r, (v << 1) ^ 1, rk);
  if (t != -1) return t;
  return -1;
}
void dfs(int v) {
  us[v] = 1;
  if (a[v] != -1) {
    while (a[v] > 0) {
      int u = get(v + 1, n, 0, n, 1, a[v] - 1);
      if (u == -1) break;
      dfs(u);
    }
  }
  for (int u : g[v])
    if (!us[u]) {
      dfs(u);
    }
  while (a[v] == -1) {
    int u = get(v + 1, n, 0, n, 1, n);
    if (u == -1) break;
    dfs(u);
  }
  path.push_back(v);
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > 0) a[i]--;
    z[i] = n;
  }
  for (int i = 0; i < n; i++) {
    if (a[i] != -1) {
      z[a[i]] = i;
      g[a[i]].push_back(i);
    }
  }
  for (int i = 0; i < n; i++) {
    add(1, 0, n, z[i], i);
  }
  make(1, 0, n);
  for (int i = 0; i < n; i++) {
    if (!us[i]) dfs(i);
  }
  for (int i = 0; i < n; i++) {
    ans[path[i]] = i;
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] + 1 << " ";
  }
  cout << "\n";
  return 0;
}
