#include <bits/stdc++.h>
using namespace std;
long long n;
long long a[500005], b[500005];
bool used[500005];
vector<long long> ans;
long long res[(long long)(2e6 + 3)];
pair<long long, long long> t[(long long)(2e6 + 3)];
void modify(long long v, long long p) {
  b[p] = v;
  t[p + n] = {v, p};
  p += n;
  for (; p > 0; p >>= 1) {
    t[p >> 1] = max(t[p], t[p ^ 1]);
  }
}
long long query(long long l, long long r) {
  pair<long long, long long> ans = {0, 0};
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l & 1) ans = max(ans, t[l++]);
    if (r & 1) ans = max(ans, t[--r]);
  }
  return ans.second;
}
void dfs(long long u) {
  used[u] = true;
  if (!used[b[u]]) dfs(b[u]);
  modify(0, u);
  long long m = query(0, a[u]);
  while (b[m] > u) {
    dfs(m);
    m = query(0, a[u]);
  }
  ans.push_back(u);
}
void topo() {
  for (long long i = 0; i < n; i++) {
    if (!used[i]) {
      dfs(i);
    }
  }
}
void solve() {
  cin >> n;
  for (long long i = 0; i < n; i++) {
    modify(n, i);
  }
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    --a[i];
    if (a[i] == -2) {
      a[i] = n;
    } else {
      modify(i, a[i]);
    }
  }
  used[n] = true;
  topo();
  for (long long i = 0; i < n; i++) {
    res[ans[i]] = i;
  }
  for (long long i = 0; i < n; i++) {
    cout << res[i] + 1 << " ";
  }
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
}
