#include <bits/stdc++.h>
using namespace std;
const int N = 5 * 1000 * 100 + 1;
int n;
pair<int, int> t[2 * N];
void build() {
  for (int i = n - 1; i > 0; --i) t[i] = max(t[i << 1], t[(i << 1) | 1]);
}
void modify(int p, pair<int, int> value) {
  for (t[p += n] = value; p > 1; p >>= 1) t[p >> 1] = max(t[p], t[p ^ 1]);
}
pair<int, int> query(int l, int r) {
  pair<int, int> res{0, 0};
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l & 1) res = max(res, t[l++]);
    if (r & 1) res = max(res, t[--r]);
  }
  return res;
}
class TaskE {
 private:
  vector<int> a, b;
  void dfs(int u, vector<int> &vis, vector<int> &topo) {
    modify(u - 1, {0, u});
    vis[u] = 1;
    if (b[u] != n + 1 && !vis[b[u]]) {
      dfs(b[u], vis, topo);
    }
    while (true) {
      pair<int, int> p = query(1, a[u]);
      if (p.first > u) {
        dfs(p.second, vis, topo);
      } else {
        break;
      }
    }
    topo.push_back(u);
  }

 public:
  void solve(istream &in, ostream &out) {
    in >> n;
    a.resize(n + 1);
    for (int i = 1; i <= n; ++i) {
      in >> a[i];
    }
    b.assign(n + 1, n + 1);
    for (int i = 1; i <= n; ++i) {
      if (a[i] != -1) {
        b[a[i]] = i;
      }
    }
    for (int i = 1; i <= n; ++i) {
      if (a[i] == -1) {
        a[i] = n + 1;
      }
    }
    for (int i = 1; i <= n; ++i) {
      t[n + i - 1] = {b[i], i};
    }
    build();
    vector<int> topo, vis(n + 1, 0);
    for (int i = 1; i <= n; ++i) {
      if (!vis[i]) {
        dfs(i, vis, topo);
      }
    }
    reverse(topo.begin(), topo.end());
    vector<int> res(n + 1, 0);
    for (int i = 0; i < (int)topo.size(); ++i) {
      res[topo[i]] = n - i;
    }
    for (int i = 1; i <= n; ++i) {
      out << res[i] << " ";
    }
    out << "\n";
  }
};
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);
  TaskE solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}
