#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500005;
pair<int, int> segmentTree[MAXN << 2];
int a[MAXN], b[MAXN], ans[MAXN];
bool visited[MAXN];
int n;
vector<int> sv;
void build(int l, int r, int index) {
  if (l == r) {
    segmentTree[index] = make_pair(b[l], l);
    return;
  }
  int mid = (l + r) >> 1;
  build(l, mid, index << 1);
  build(mid + 1, r, (index << 1) + 1);
  segmentTree[index] =
      max(segmentTree[index << 1], segmentTree[(index << 1) + 1]);
}
void update(int pos, int val, int l, int r, int index) {
  if (l == r) {
    segmentTree[index] = make_pair(val, segmentTree[index].second);
    return;
  }
  int mid = (l + r) >> 1;
  if (pos <= mid) {
    update(pos, val, l, mid, index << 1);
  } else {
    update(pos, val, mid + 1, r, (index << 1) + 1);
  }
  segmentTree[index] =
      max(segmentTree[index << 1], segmentTree[(index << 1) + 1]);
}
pair<int, int> query(int L, int R, int l, int r, int index) {
  pair<int, int> ret;
  if (L > R) {
    return make_pair(0, 0);
  }
  if (L <= l && r <= R) {
    return segmentTree[index];
  }
  int mid = (l + r) >> 1;
  if (L <= mid) {
    ret = max(ret, query(L, R, l, mid, index << 1));
  }
  if (R > mid) {
    ret = max(ret, query(L, R, mid + 1, r, (index << 1) + 1));
  }
  return ret;
}
void dfs(int node) {
  visited[node] = true;
  update(node, 0, 1, n, 1);
  if (b[node] != n + 1 && !visited[b[node]]) {
    dfs(b[node]);
  }
  while (1) {
    pair<int, int> mx = query(1, a[node] - 1, 1, n, 1);
    if (mx.first > node) {
      dfs(mx.second);
    } else {
      break;
    }
  }
  sv.push_back(node);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    b[i] = 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;
    }
  }
  build(1, n, 1);
  for (int i = 1; i <= n; i++) {
    if (!visited[i]) {
      dfs(i);
    }
  }
  for (int i = 0; i < sv.size(); i++) {
    ans[sv[i]] = i + 1;
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}
