#include <bits/stdc++.h>
using namespace std;
const long long maxn = 4e6 + 100;
const long long mod = 1e9 + 7;
const long long inf = 1e18;
long long n, a[maxn], b[maxn];
bool vis[maxn];
vector<pair<long long, long long> > g[maxn];
vector<long long> vec;
void bld(long long id, long long s, long long e) {
  g[id].resize(e - s);
  if (e - s == 1) {
    g[id][0] = make_pair(b[s], s);
    return;
  }
  long long mid = (s + e) / 2;
  bld((id << 1), s, mid);
  bld((id << 1 | 1), mid, e);
  merge(g[(id << 1)].begin(), g[(id << 1)].end(), g[(id << 1 | 1)].begin(),
        g[(id << 1 | 1)].end(), g[id].begin());
  return;
}
void dfs(long long v);
void solve(long long id, long long s, long long e, long long l, long long r,
           long long x) {
  if (r <= s || e <= l) return;
  if (l <= s && e <= r) {
    while (!g[id].empty() && g[id].back().first >= x) {
      long long v = g[id].back().second;
      g[id].pop_back();
      dfs(v);
    }
    return;
  }
  long long mid = (s + e) >> 1;
  solve((id << 1), s, mid, l, r, x);
  solve((id << 1 | 1), mid, e, l, r, x);
  return;
}
void dfs(long long v) {
  if (vis[v]) return;
  vis[v] = 1;
  dfs(b[v]);
  solve(1, 0, n, 0, a[v], v);
  vec.push_back(v);
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  fill(b, b + n, n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == -1) a[i] = n + 1;
    a[i]--;
    b[a[i]] = i;
  }
  bld(1, 0, n);
  vis[n] = 1;
  for (long long i = 0; i < n; i++) {
    dfs(i);
  }
  for (long long i = 0; i < n; i++) {
    a[vec[i]] = i + 1;
  }
  for (long long i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
  return 0;
}
