#include <bits/stdc++.h>
using namespace std;
const int df = (int)(1e6);
int v[100000 + 5], sol[100000 + 5];
bool viz[10 * 100000 + 5], fv[10 * 100000 + 5];
void nu() {
  cout << -1;
  exit(0);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int i, j, z;
  for (i = 1; i <= n; i++) cin >> v[i];
  if (v[1] > 1) nu();
  fill(begin(sol), end(sol), df);
  for (i = n; i > 1; i--)
    if (v[i] != v[i - 1]) {
      sol[i] = v[i - 1];
      viz[v[i - 1]] = 1;
    }
  int M = (*max_element(v + 1, v + n + 1)) - 1;
  for (i = 1, j = 0; i <= n; i++)
    if (sol[i] == df) {
      while (j <= M && viz[j] == 1) j++;
      if (j > M) continue;
      sol[i] = j;
      viz[j] = 1;
      j++;
    }
  int mex = 0;
  for (i = 1; i <= n; i++) {
    fv[sol[i]] = 1;
    if (mex == sol[i]) do {
        mex++;
      } while (fv[mex] != 0);
    if (mex != v[i]) nu();
  }
  for (i = 1; i <= n; i++) cout << sol[i] << ' ';
  return 0;
}
