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>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
const long long mod = 998244353;
inline long long add(long long a, long long b) {
  a += b;
  if (a >= mod) a -= mod;
  return a;
}
inline long long sub(long long a, long long b) {
  a -= b;
  if (a < 0) a += mod;
  return a;
}
inline long long mul(long long a, long long b) { return (a * 1ll * b) % mod; }
inline long long powmod(long long a, long long b) {
  long long rt = 1;
  while (b > 0) {
    if (b & 1) rt = mul(rt, a);
    a = mul(a, a);
    b >>= 1;
  }
  return rt;
}
inline long long inv(long long a) { return powmod(a, mod - 2); }
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
void solve() {
  long long n;
  cin >> n;
  long long b[n];
  for (long long i = 0; i < n; i++) cin >> b[i];
  long long final[n];
  long long end = b[n - 1];
  for (long long i = n - 1; i >= 0; i--) {
    if (b[i] > (i + 1)) {
      cout << -1 << '\n';
      return;
    }
  }
  if (n == 1) {
    if (b[0] == 0)
      cout << 2 << '\n';
    else
      cout << 0 << '\n';
    return;
  }
  long long maxq = 0;
  final[0] = -1;
  for (long long i = n - 1; i > 0; i--) {
    maxq = b[i];
    if (b[i] == 0) {
      if (i == n - 1)
        maxq = 1e6;
      else
        maxq = b[i + 1] - 1;
      while (i >= 0) {
        if (maxq == 0) maxq = (long long)1e6;
        final[i] = maxq;
        maxq--;
        i--;
      }
      break;
    }
    if (i != n - 1 and b[i] == b[i - 1])
      final[i] = max(b[i + 1] - 1, maxq + 1);
    else if (b[i] != b[i - 1])
      final[i] = b[i - 1];
    else
      final[i] = maxq - 1;
  }
  if (final[0] == -1) {
    if (b[0] == 0)
      final[0] = max(maxq - 1, final[1] - 1);
    else
      final[0] = 0;
    if (final[0] <= 0 and b[0] == 0) final[0] = (long long)1e6;
  }
  for (long long i = 0; i < n; i++) cout << final[i] << " ";
  cout << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL),
      cout << setprecision(14);
  ;
  long long t = 1;
  while (t--) {
    solve();
  }
}
