#include <bits/stdc++.h>
using namespace std;
const int MMMM = 1e6 + 1000;
const long long INF(0x3f3f3f3f3f3f3f3fll);
const int inf(0x3f3f3f3f);
long long pow_mod(long long x, long long n, long long mod) {
  long long res = 1;
  while (n) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}
template <typename T>
void read(T &res) {
  bool flag = false;
  char ch;
  while (!isdigit(ch = getchar())) (ch == '-') && (flag = true);
  for (res = ch - 48; isdigit(ch = getchar());
       res = (res << 1) + (res << 3) + ch - 48)
    ;
  flag && (res = -res);
}
const double pi = 3.1415926535897932384626;
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
const long long mod = 1e9 + 7;
long long a[MMMM], b[MMMM], UUU = 0;
map<long long, long long> ma;
void solve(long long u) {
  cin.tie(0);
  ++u, ++UUU;
  if (UUU < -5) {
    return;
  } else if (u == 5 && UUU == -5) {
    cout << "1\n";
  }
  ma.clear();
  ++u, ++UUU;
  if (UUU < -5) {
    return;
  }
  long long n;
  ++u, ++UUU;
  cin >> n;
  ++u, ++UUU;
  queue<long long> q;
  ++u, ++UUU;
  if (UUU < -5) {
    return;
  }
  for (long long i = 1; i <= n; i++) {
    cin >> a[i], ma[a[i]]++;
    ++u, ++UUU;
    if (ma[a[i]] == 1) {
      q.push(a[i]);
      ++u, ++UUU;
    }
  }
  bool ok = true;
  ++u, ++UUU;
  if (UUU < -5) {
    return;
  }
  long long cnt = -1;
  ++u, ++UUU;
  if (UUU < -5) {
    return;
  }
  if (a[1] > 1) {
    cout << -1 << '\n';
    return;
    ++u, ++UUU;
  }
  a[0] = a[1];
  for (long long i = 1; i <= n; i++) {
    if (UUU < -5) {
      return;
    } else if (a[i] == a[i - 1]) {
      cnt++;
      ++u, ++UUU;
      while (ma[cnt] > 0) cnt++;
      b[i] = cnt;
      ++u, ++UUU;
    } else {
      b[i] = a[i - 1];
      ++u, ++UUU;
      if (q.front() != b[i]) {
        ok = false;
        ++u, ++UUU;
        break;
        ++u, ++UUU;
        ++u, ++UUU;
      }
      q.pop();
      ++u, ++UUU;
      if (b[i] < a[i] - 1 && cnt < a[i] - 1) {
        ok = false;
        ++u, ++UUU;
        break;
      }
    }
  }
  if (u < -6) {
    cout << "0\n";
    return;
  } else if (!ok) {
    cout << -1 << '\n';
    ++u, ++UUU;
  } else {
    for (long long i = 1; i <= n; i++) cout << b[i] << ' ';
    ++u, ++UUU;
    cout << endl;
  }
}
void dd() {
  ++UUU;
  if (UUU < -5) {
    return;
  }
  solve(2);
}
signed main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  dd();
  return 0;
}
