Given an array a of length n, find another array, b, of length n such that:

  * for each i (1 ≤ i ≤ n) MEX(\\{b_1, b_2, …, b_i\})=a_i. 



The MEX of a set of integers is the smallest non-negative integer that doesn't belong to this set.

If such array doesn't exist, determine this.

Input

The first line contains an integer n (1 ≤ n ≤ 10^5) — the length of the array a.

The second line contains n integers a_1, a_2, …, a_n (0 ≤ a_i ≤ i) — the elements of the array a. It's guaranteed that a_i ≤ a_{i+1} for 1≤ i < n.

Output

If there's no such array, print a single line containing -1.

Otherwise, print a single line containing n integers b_1, b_2, …, b_n (0 ≤ b_i ≤ 10^6)

If there are multiple answers, print any.

Examples

Input


3
1 2 3


Output


0 1 2 

Input


4
0 0 0 2


Output


1 3 4 0 

Input


3
1 1 3


Output


0 2 1 

Note

In the second test case, other answers like [1,1,1,0], for example, are valid.
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using lld = long double;
const int oo = 0x3f3f3f3f;
const ll MOD = 1000000007;
const int N = 1e5 + 10;
int bit[N];
void upd(int x) {
  if (x == 0) {
    bit[0] = 1;
    return;
  }
  while (x < N) {
    bit[x] += 1;
    x += (x & -x);
  }
}
int qry(int x) {
  int ans = 0;
  while (x > 0) {
    ans += bit[x];
    x -= (x & -x);
  }
  if (bit[0]) ans++;
  return ans;
}
int get() {
  int l = -1;
  int h = N;
  while (l + 1 < h) {
    int mid = (l + h) >> 1;
    if (qry(mid) > mid) {
      l = mid;
    } else {
      h = mid;
    }
  }
  return h;
}
void solve() {
  int n;
  cin >> n;
  vector<int> mex(n, -1), ar(n);
  for (int i = 0; i < n; i++) cin >> ar[i];
  bool ok = 1;
  set<int> hs;
  for (int i = 0; i < n; i++) hs.insert(i);
  for (int i = 1; i < n; i++) {
    if (ar[i] != ar[i - 1]) {
      mex[i] = ar[i - 1];
      hs.erase(mex[i]);
    }
  }
  hs.erase(ar[n - 1]);
  for (int i = 0; i < n; i++) {
    if (mex[i] == -1) {
      if (hs.empty()) {
        if (i)
          mex[i] = mex[i - 1];
        else
          ok = 0;
        continue;
      }
      mex[i] = *hs.begin();
      hs.erase(*hs.begin());
    }
    upd(mex[i]);
    if (get() != ar[i]) ok = 0;
  }
  if (!ok) {
    cout << "-1\n";
    return;
  }
  for (int i : mex) cout << i << " ";
  cout << '\n';
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
