#include <bits/stdc++.h>
using namespace std;
template <class X, class Y>
void amax(X& x, const Y& y) {
  if (x < y) x = y;
}
template <class X, class Y>
void amin(X& x, const Y& y) {
  if (x > y) x = y;
}
const int INF = 1e9 + 10;
const long long INFL = 1e18 + 10;
const int MAX = 5e5 + 10;
int n, ntp;
int a[MAX], b[MAX], topo[MAX], res[MAX];
bool mark[MAX];
pair<int, int> ste[MAX * 4];
void build(int id, int l, int r) {
  if (l == r) {
    ste[id] = make_pair(b[l], l);
    return;
  }
  int mid = (l + r) / 2;
  build(id * 2, l, mid);
  build(id * 2 + 1, mid + 1, r);
  if (ste[id * 2].first > ste[id * 2 + 1].first)
    ste[id] = ste[id * 2];
  else
    ste[id] = ste[id * 2 + 1];
}
void update(int id, int l, int r, int p, int value) {
  if (p < l || p > r) return;
  if (l == r) {
    ste[id] = make_pair(value, l);
    return;
  }
  int mid = (l + r) / 2;
  update(id * 2, l, mid, p, value);
  update(id * 2 + 1, mid + 1, r, p, value);
  if (ste[id * 2].first > ste[id * 2 + 1].first)
    ste[id] = ste[id * 2];
  else
    ste[id] = ste[id * 2 + 1];
}
pair<int, int> query(int id, int l, int r, int u, int v) {
  if (v < l || u > r) return make_pair(0, 0);
  if (u <= l && r <= v) return ste[id];
  int mid = (l + r) / 2;
  pair<int, int> le = query(id * 2, l, mid, u, v);
  pair<int, int> ri = query(id * 2 + 1, mid + 1, r, u, v);
  if (le.first > ri.first) return le;
  return ri;
}
void visit(int u) {
  mark[u] = true;
  update(1, 1, n, u, 0);
  if (b[u] != n + 1 && !mark[b[u]]) visit(b[u]);
  while (true) {
    pair<int, int> ret = query(1, 1, n, 1, a[u] - 1);
    if (ret.first <= u) break;
    visit(ret.second);
  }
  topo[++ntp] = u;
}
void process() {
  cin >> n;
  for (int i = 1; i <= n; i++) b[i] = n + 1;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] == -1) a[i] = n + 1;
    b[a[i]] = i;
  }
  build(1, 1, n);
  for (int i = 1; i <= n; i++)
    if (!mark[i]) visit(i);
  for (int i = 1; i <= n; i++) res[topo[i]] = i;
  for (int i = 1; i <= n; i++) cout << res[i] << " ";
}
int main() {
  ios_base::sync_with_stdio(false);
  process();
}
