/*  -*- coding: utf-8 -*-
 *
 * 3006.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int MAX_E2 = 1 << 18; // = 262144

/* typedef */

typedef queue<int> qi;

struct Elm {
  int v;
  Elm *nxt;
  Elm(): v(), nxt() {}
  Elm(int _v): v(_v), nxt() {}
  Elm(int _v, Elm *_nxt): v(_v), nxt(_nxt) {}
};

static Elm buf[MAX_N], *bpt = buf;

struct SList {
  Elm *head, *tail;
  int sz;
  SList(): head(), tail(), sz(0) {}

  void clear() { tail = head = NULL, sz = 0; }

  int size() { return sz; }
  bool empty() { return (sz == 0); }
  int front() { return (head != NULL) ? head->v : -1; }

  void add(int v) {
    Elm *ept = bpt++;
    ept->v = v, ept->nxt = NULL;

    if (head == NULL)
      head = tail = ept, sz = 1;
    else {
      tail->nxt = ept;
      tail = ept;
      sz++;
    }
  }

  void erase() {
    if (head != NULL) {
      head = head->nxt;
      sz--;
      if (head == NULL) tail = NULL;
    }
  }

  void append(const SList &sl) {
    if (head == NULL)
      *this = sl;
    else {
      tail->nxt = sl.head;
      tail = sl.tail;
      sz += sl.sz;
    }
  }
};

template <typename T, const int MAX_E2>
struct SegTreeMin {
  int n, e2;
  T nodes[MAX_E2], def;
  SegTreeMin() {}

  void init(int _n, T _def) {
    n = _n; def = _def;
    for (e2 = 1; e2 < n; e2 <<= 1);
    fill(nodes, nodes + MAX_E2, def);
  }

  T &get(int i) { return nodes[e2 - 1 + i]; }

  void set(int i, T v) {
    int j = e2 - 1 + i;
    nodes[j] = v;
    while (j > 0) {
      j = (j - 1) / 2;
      nodes[j] = min<T>(nodes[j * 2 + 1], nodes[j * 2 + 2]);
    }
  }

  void setall() {
    for (int j = e2 - 2; j >= 0; j--)
      nodes[j] = min<T>(nodes[j * 2 + 1], nodes[j * 2 + 2]);
  }

  T min_range(int r0, int r1, int k, int i0, int i1) {
    if (r1 <= i0 || i1 <= r0) return def;
    if (r0 <= i0 && i1 <= r1) return nodes[k];

    int im = (i0 + i1) / 2;
    T v0 = min_range(r0, r1, k * 2 + 1, i0, im);
    T v1 = min_range(r0, r1, k * 2 + 2, im, i1);
    return min<T>(v0, v1);
  }
  T min_range(int r0, int r1) { return min_range(r0, r1, 0, 0, e2); }
};

/* global variables */

int ps[MAX_N], cs[MAX_N];
SList sls[MAX_N + 1];
SegTreeMin<int,MAX_E2> sta, stq;

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  sta.init(n, n);
  for (int i = 0; i < n; i++) sta.get(i) = i;
  sta.setall();
  stq.init(n + 1, n);
  
  memset(cs, -1, sizeof(cs));
  qi wq;

  for (int i = 0; i < n; i++) {
    int pi;
    scanf("%d", &pi);
    pi--;

    if (cs[pi] < 0) {
      cs[pi] = i;
      sta.set(pi, n);
    }
    else {
      if (sls[pi].empty()) wq.push(pi);
      sls[pi].add(i);
      stq.set(pi, pi);
    }
  }
  //printf("wq=%lu\n", wq.size());

  while (! wq.empty()) {
    int u = wq.front(); wq.pop();
    SList &slu = sls[u];
    if (slu.empty()) continue;

    int qu = (u >= n) ? 0 : u + 1;
    int v = stq.min_range(qu, n);
    //printf("u=%d, v=%d\n", u, v);

    while (! slu.empty()) {
      int ai = sta.min_range(qu, v);
      if (ai >= n) break;

      cs[ai] = slu.front();
      sta.set(ai, n);
      slu.erase();
    }

    stq.set(u, n);
    if (! slu.empty()) {
      if (stq.get(v) >= n) {
	stq.set(v, v);
	wq.push(v);
      }
      sls[v].append(slu);
      slu.clear();
    }
  }

  for (int i = 0; i < n; i++) printf("%d\n", cs[i] + 1);
  return 0;
}



Measured memory_bytes: 9760