#include <bits/stdc++.h>
using namespace std;
inline long long mod(long long n, long long m) {
  long long ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}
long long gcd(long long a, long long b) {
  return (b == 0LL ? a : gcd(b, a % b));
}
long long exp(long long a, long long b, long long m) {
  if (b == 0LL) return 1LL;
  if (b == 1LL) return mod(a, m);
  long long k = mod(exp(a, b / 2, m), m);
  if (b & 1LL) {
    return mod(a * mod(k * k, m), m);
  } else
    return mod(k * k, m);
}
const int N = 500100;
int a[N], rev[N];
int p[N];
int chamou[N];
pair<int, int> tree[4 * N];
void build(int no, int i, int j) {
  if (i == j)
    tree[no] = pair<int, int>(rev[i], i);
  else {
    int mid = (i + j) >> 1, l = no << 1, r = no << 1 | 1;
    build(l, i, mid);
    build(r, mid + 1, j);
    tree[no] = max(tree[l], tree[r]);
  }
}
void upd(int no, int i, int j, int p) {
  if (i == j)
    tree[no] = pair<int, int>(0, i);
  else {
    int mid = (i + j) >> 1, l = no << 1, r = no << 1 | 1;
    if (p <= mid)
      upd(l, i, mid, p);
    else
      upd(r, mid + 1, j, p);
    tree[no] = max(tree[l], tree[r]);
  }
}
pair<int, int> mx(int no, int i, int j, int a, int b) {
  if (i > j || i > b || j < a) return pair<int, int>(0, 0);
  if (a <= i and j <= b) return tree[no];
  int mid = (i + j) >> 1, l = no << 1, r = no << 1 | 1;
  return max(mx(l, i, mid, a, b), mx(r, mid + 1, j, a, b));
}
int vis[N];
vector<int> order;
int n;
void dfs(int v) {
  if (vis[v]) return;
  vis[v] = 1;
  upd(1, 1, n, v);
  if (rev[v] != n + 1 and !vis[rev[v]]) dfs(rev[v]);
  while (true) {
    pair<int, int> x = mx(1, 1, n, 1, a[v] - 1);
    if (x.first > v)
      dfs(x.second);
    else
      break;
  }
  order.push_back(v);
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (int i = 1; i <= n; i++) rev[i] = n + 1;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] == -1) {
      a[i] = n + 1;
    } else {
      rev[a[i]] = i;
    }
  }
  build(1, 1, n);
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i);
  int cur = 0;
  for (int x : order) p[x] = ++cur;
  for (int i = 1; i <= n; i++) cout << p[i] << " \n"[i == n];
}
