#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &num) {
  T x = 0, f = 1;
  char ch = getchar();
  for (; ch > '9' || ch < '0'; ch = getchar())
    if (ch == '-') f = -1;
  for (; ch <= '9' && ch >= '0'; ch = getchar())
    x = (x << 3) + (x << 1) + (ch ^ '0');
  num = x * f;
}
int n, a[1000005], b[1000005], o[1000005], tt, ans[1000005];
bool vis[1000005];
pair<int, int> tr[1000005 << 2];
void build(int ind, int l, int r) {
  if (l == r) return tr[ind] = make_pair(b[l], l), void();
  int mid = (l + r) >> 1;
  build(ind << 1, l, mid);
  build(ind << 1 | 1, mid + 1, r);
  tr[ind] = max(tr[ind << 1], tr[ind << 1 | 1]);
}
void update(int ind, int l, int r, int x) {
  if (l == r) return tr[ind] = make_pair(0, 0), void();
  int mid = (l + r) >> 1;
  if (x <= mid)
    update(ind << 1, l, mid, x);
  else
    update(ind << 1 | 1, mid + 1, r, x);
  tr[ind] = max(tr[ind << 1], tr[ind << 1 | 1]);
}
pair<int, int> query(int ind, int l, int r, int x, int y) {
  if (x <= l && r <= y) return tr[ind];
  int mid = (l + r) >> 1;
  if (x > mid)
    return query(ind << 1 | 1, mid + 1, r, x, y);
  else if (y <= mid)
    return query(ind << 1, l, mid, x, y);
  else
    return max(query(ind << 1, l, mid, x, y),
               query(ind << 1 | 1, mid + 1, r, x, y));
}
void dfs(int x) {
  vis[x] = 1;
  update(1, 1, n, x);
  if (b[x] <= n && !vis[b[x]]) dfs(b[x]);
  if (a[x] > 1) {
    while (1) {
      pair<int, int> now = query(1, 1, n, 1, a[x] - 1);
      if (now.first > x)
        dfs(now.second);
      else
        break;
    }
  }
  o[++tt] = x;
}
int main() {
  read(n);
  for (int i = 1; i <= n; i++) {
    read(a[i]);
    if (~a[i])
      b[a[i]] = i;
    else
      a[i] = n + 1;
  }
  for (int i = 1; i <= n; i++)
    if (!b[i]) b[i] = n + 1;
  build(1, 1, n);
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i);
  for (int i = 1; i <= n; i++) ans[o[i]] = i;
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  return 0;
}
