#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  int prev = -1;
  bool invalid = false;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    invalid = (prev > a[i]) || (a[i] > i + 1);
    prev = a[i];
  }
  if (invalid) {
    cout << -1 << endl;
    return;
  }
  int mex = a.back();
  vector<int> ans(n);
  bool first = true;
  for (int i = 0, cnt = 0; i < n; i++) {
    if (first && i == mex) {
      first = false;
      cnt++;
    }
    ans[i] = cnt++;
  }
  for (int i = n - 1; ~i; i--) {
    if (ans[a[i]] == a[i]) {
      swap(ans[a[i]], ans[i + 1]);
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << " \n"[i + 1 == n];
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
