#include <bits/stdc++.h>
using namespace std;
bool exceed(long long x, long long y, long long m) { return x >= m / y + 1; }
struct SegTree {
  int size;
  vector<pair<long long, long long> > seg;
  SegTree() {}
  SegTree(int size) {
    this->size = size;
    seg.resize(1 << (size + 1));
  }
  pair<long long, long long> Ident() {
    return pair<long long, long long>(-1e18, -1e18);
  }
  pair<long long, long long> ope(pair<long long, long long> a,
                                 pair<long long, long long> b) {
    return max(a, b);
  }
  void init() {
    for (int i = 0; i < (1 << (size + 1)); i++) seg[i] = Ident();
  }
  void update(int i, pair<long long, long long> val) {
    i += (1 << size);
    seg[i] = val;
    while (i > 1) {
      i /= 2;
      seg[i] = ope(seg[i * 2], seg[i * 2 + 1]);
    }
  }
  pair<long long, long long> query(int a, int b, int k, int l, int r) {
    if (b < l || r < a) return Ident();
    if (a <= l && r <= b) return seg[k];
    pair<long long, long long> lval = query(a, b, k * 2, l, (l + r) / 2);
    pair<long long, long long> rval =
        query(a, b, k * 2 + 1, (l + r) / 2 + 1, r);
    return ope(lval, rval);
  }
  pair<long long, long long> query(int a, int b) {
    if (a > b) return Ident();
    return query(a, b, 1, 0, (1 << size) - 1);
  }
};
long long n;
long long a[500005], b[500005];
SegTree seg(19);
bool used[500005];
long long ans[500005];
vector<long long> topo;
void dfs(int v) {
  used[v] = true;
  seg.update(v, pair<long long, long long>(-1e18, -1e18));
  if (a[v] <= n && !used[a[v]]) dfs(a[v]);
  while (1) {
    pair<long long, long long> res = seg.query(1, b[v] - 1);
    if (res.first <= v) break;
    dfs(res.second);
  }
  topo.push_back(v);
}
int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (long long(i) = (1); (i) <= (n); (i)++) {
    cin >> a[i];
    if (a[i] == -1) a[i] = n + 1;
  }
  for (long long(i) = (1); (i) <= (n); (i)++) b[a[i]] = i;
  for (long long(i) = (1); (i) <= (n); (i)++)
    if (b[i] == 0) b[i] = n + 1;
  seg.init();
  for (long long(i) = (1); (i) <= (n); (i)++)
    seg.update(i, pair<long long, long long>(a[i], i));
  for (long long(i) = (1); (i) <= (n); (i)++)
    if (!used[i]) dfs(i);
  reverse((topo).begin(), (topo).end());
  for (long long(i) = 0; (i) < (long long)(topo).size(); (i)++)
    ans[topo[i]] = i + 1;
  for (long long(i) = (1); (i) <= (n); (i)++) cout << ans[i] << " ";
  cout << endl;
  return 0;
}
