#include <bits/stdc++.h>
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
int IT_MAX = 1 << 19;
const long long MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 1234567890123456789ll;
const double PI = acos(-1);
const double ERR = 1E-11;
pair<int, int> operator+(pair<int, int> a, pair<int, int> b) {
  return pair<int, int>(a.first + b.first, a.second + b.second);
}
pair<int, int> indt[1100000];
void update(int p, pair<int, int> v) {
  p += IT_MAX - 1;
  indt[p] = indt[p] + v;
  for (p /= 2; p; p /= 2) indt[p] = max(indt[2 * p], indt[2 * p + 1]);
}
pair<int, int> getmx(int p1, int p2) {
  p1 += IT_MAX - 1;
  p2 += IT_MAX - 1;
  pair<int, int> rv = pair<int, int>(-2 * INF, -INF);
  while (p1 <= p2) {
    if (p1 % 2 == 1) rv = max(rv, indt[p1++]);
    if (p2 % 2 == 0) rv = max(rv, indt[p2--]);
    p1 /= 2, p2 /= 2;
  }
  return rv;
}
int N;
int A[500050];
int B[500050];
int ans[500050];
bool dchk[500050];
vector<int> Vu;
void DFS(int n) {
  update(n, pair<int, int>(-INF * 2, 0));
  dchk[n] = true;
  while (1) {
    if (A[n] != N + 1 && !dchk[A[n]]) {
      DFS(A[n]);
      continue;
    }
    pair<int, int> rv = getmx(1, B[n] - 1);
    if (rv.first <= n) break;
    DFS(rv.second);
  }
  Vu.push_back(n);
}
int main() {
  int i;
  scanf("%d", &N);
  for (i = 1; i <= N; i++) B[i] = N + 1;
  for (i = 1; i <= N; i++) {
    scanf("%d", &A[i]);
    if (A[i] == -1)
      A[i] = N + 1;
    else
      B[A[i]] = i;
  }
  for (i = 1; i <= N; i++) update(i, pair<int, int>(A[i], i));
  int v = N;
  for (i = 1; i <= N; i++) {
    if (dchk[i]) continue;
    DFS(i);
    for (auto it : Vu) ans[it] = v--;
    Vu.clear();
  }
  for (i = 1; i <= N; i++) printf("%d ", ans[i]);
  return !printf("\n");
}
