#include <bits/stdc++.h>
using namespace std;
const int maxn = 500000 + 5;
int n;
int A[maxn], B[maxn], flag[maxn];
vector<int> ans;
int ql, qr, updateVal, updatePos;
int tree[maxn];
int maxv[maxn * 4];
int query(int o, int L, int R) {
  int M = L + (R - L) / 2;
  int u, v;
  u = v = 0;
  if (ql <= L && R <= qr) return maxv[o];
  if (ql <= M) {
    u = query(o * 2, L, M);
  }
  if (qr > M) {
    v = query(o * 2 + 1, M + 1, R);
  }
  if (tree[u] > tree[v])
    return u;
  else
    return v;
}
void update(int o, int L, int R) {
  int M = L + (R - L) / 2;
  if (L == R) {
    maxv[o] = updateVal;
  } else {
    int lc = o << 1;
    int rc = lc | 1;
    if (updatePos <= M) {
      update(lc, L, M);
    } else {
      update(rc, M + 1, R);
    }
    if (tree[maxv[lc]] > tree[maxv[rc]]) {
      maxv[o] = maxv[lc];
    } else {
      maxv[o] = maxv[rc];
    }
  }
}
int nextNode(int u) {
  int v = B[u];
  if (B[u] != n + 1 && !flag[v]) return v;
  if (A[u] <= 1) {
    return 0;
  } else {
    ql = 1;
    qr = A[u] - 1;
    v = query(1, 1, n);
    if (B[v] > u) {
      return v;
    } else {
      return 0;
    }
  }
}
void dfs(int u, int deep) {
  flag[u] = 1;
  tree[u] = 0;
  updatePos = u;
  updateVal = 0;
  update(1, 1, n);
  int v;
  while (1) {
    v = nextNode(u);
    if (v == 0) {
      break;
    } else {
      dfs(v, deep + 4);
    }
  }
  ans.push_back(u);
}
void init(int len) {
  ans.clear();
  memset(flag, 0, sizeof(flag));
  memset(maxv, 0, sizeof(maxv));
  for (int i = 1; i <= len; ++i) {
    B[i] = len + 1;
  }
}
int main() {
  while (cin >> n) {
    init(n);
    for (int i = 1; i <= n; ++i) {
      cin >> A[i];
      if (A[i] != -1) {
        B[A[i]] = i;
      } else {
        A[i] = n + 1;
      }
    }
    tree[0] = 0;
    for (int i = 1; i <= n; ++i) {
      tree[i] = B[i];
    }
    for (int i = 1; i <= n; ++i) {
      updatePos = i;
      updateVal = i;
      update(1, 1, n);
    }
    for (int i = 1; i <= n; ++i) {
      if (!flag[i]) {
        dfs(i, 0);
      }
    }
    reverse(ans.begin(), ans.end());
    for (int i = 0; i < ans.size(); ++i) {
      A[ans[i]] = n--;
    }
    for (int i = 1; i <= ans.size(); ++i) {
      if (i == 1)
        printf("%d", A[i]);
      else
        printf(" %d", A[i]);
    }
    printf("\n");
  }
  return 0;
}
