#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  set<long long> nums;
  for (long long i = 0; i <= n; i++) {
    nums.insert(i);
  }
  vector<long long> b(n);
  vector<long long> c;
  vector<long long> d;
  for (long long i = 0; i < n; i++) {
    d.push_back(i);
    c.clear();
    while (*nums.begin() < a[i]) {
      c.push_back(*nums.begin());
      nums.erase(nums.begin());
    }
    reverse(c.begin(), c.end());
    if (d.size() < c.size()) {
      cout << -1 << endl;
      return 0;
    }
    while (!c.empty()) {
      auto it = lower_bound(a.begin(), a.end(), c.back());
      if (it != a.end() && *it == c.back() &&
          distance(a.begin(), it) >= d.back()) {
        cout << -1 << endl;
        return 0;
      }
      b[d.back()] = c.back();
      c.pop_back();
      d.pop_back();
    }
  }
  for (long long x : d) {
    b[x] = n + 1;
  }
  for (long long i = 0; i < n; i++) {
    cout << b[i] << " ";
  }
  cout << endl;
  return 0;
}
