#include <bits/stdc++.h>
int a[1 << 20];
int b[1 << 20];
std::pair<int, int> tree[1 << 22];
void init(int lb, int rb, int node) {
  if (lb == rb) {
    tree[node] = {b[lb], lb};
    return;
  }
  int mid = (lb + rb) / 2;
  init(lb, mid, node << 1);
  init(mid + 1, rb, node << 1 | 1);
  tree[node] = std::max(tree[node << 1], tree[node << 1 | 1]);
}
void erase(int lb, int rb, int key, int node) {
  if (lb == rb) {
    tree[node] = {0, lb};
    return;
  }
  int mid = (lb + rb) / 2;
  if (key <= mid)
    erase(lb, mid, key, node << 1);
  else
    erase(mid + 1, rb, key, node << 1 | 1);
  tree[node] = std::max(tree[node << 1], tree[node << 1 | 1]);
}
std::pair<int, int> query(int lb, int rb, int begin, int end, int node) {
  if (begin > end) return {0, 0};
  if (begin <= lb && rb <= end) return tree[node];
  int mid = (lb + rb) / 2;
  std::pair<int, int> ans = {0, 0};
  if (begin <= mid) ans = std::max(ans, query(lb, mid, begin, end, node << 1));
  if (mid + 1 <= end)
    ans = std::max(ans, query(mid + 1, rb, begin, end, node << 1 | 1));
  return ans;
}
int N;
bool visited[1 << 20];
std::vector<int> list;
int ans[1 << 20];
void dfs(int here) {
  erase(1, N, here, 1);
  visited[here] = true;
  if (b[here] != N + 1 && !visited[b[here]]) {
    dfs(b[here]);
  }
  int idx, there;
  while (1) {
    std::tie(idx, there) = query(1, N, 1, a[here] - 1, 1);
    if (idx <= here) break;
    dfs(there);
  }
  list.push_back(here);
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin >> N;
  for (int i = 1; i <= N; ++i) {
    b[i] = N + 1;
  }
  for (int i = 1; i <= N; ++i) {
    std::cin >> a[i];
    if (a[i] != -1) {
      b[a[i]] = i;
    }
  }
  for (int i = 1; i <= N; ++i) {
    if (a[i] == -1) {
      a[i] = N + 1;
    }
  }
  init(1, N, 1);
  for (int start = 1; start <= N; ++start) {
    if (visited[start]) continue;
    dfs(start);
  }
  int cnt = 0;
  for (const auto& node : list) {
    ans[node] = ++cnt;
  }
  for (int i = 1; i <= N; ++i) {
    std::cout << ans[i] << ' ';
  }
  std::cout << '\n';
  return 0;
}
