#include <bits/stdc++.h>
using namespace std;
void shikhar7s(long long int cas) {
  long long int n, i;
  cin >> n;
  long long int a[n], b[n], vis[1000005] = {0};
  memset(b, -1, sizeof(b));
  for (i = 0; i < n; i++) {
    cin >> a[i];
    if (i && a[i] != a[i - 1]) {
      b[i] = a[i - 1];
      vis[b[i]] = 1;
    }
  }
  vis[a[n - 1]] = 1;
  long long int j = 0;
  while (vis[j]) j++;
  for (i = 0; i < n; i++) {
    if (b[i] == -1) {
      b[i] = j;
      vis[j] = 1;
      while (vis[j]) j++;
    } else {
      if (j < a[i]) {
        cout << -1;
        return;
      }
    }
  }
  for (i = 0; i < n; i++) cout << b[i] << " ";
}
signed main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int t = 1;
  long long int cas = 1;
  while (cas <= t) {
    shikhar7s(cas);
    cas++;
  }
  return 0;
}
