#include <bits/stdc++.h>
const int MAXN = 3e5 + 5;
int n, a[MAXN], b[MAXN];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  for (int i = 2; i <= n; ++i) {
    if (a[i] < a[i - 1]) {
      puts("-1");
      return 0;
    }
  }
  std::vector<int> S;
  if (a[1] == 0)
    S.push_back(1);
  else if (a[1] == 1)
    b[1] = 0;
  else {
    puts("-1");
    return 0;
  }
  for (int i = 2; i <= n; ++i) {
    S.push_back(i);
    if (a[i] == a[i - 1]) {
      continue;
    } else {
      int d = a[i] - a[i - 1];
      if ((int)S.size() < d) {
        puts("-1");
        return 0;
      }
      for (int j = 0; j <= d - 1; ++j) {
        b[S.back()] = a[i - 1] + j;
        S.pop_back();
      }
    }
  }
  for (auto x : S) b[x] = 1e6 - 1;
  for (int i = 1; i <= n; ++i) printf("%d ", b[i]);
  puts("");
  return 0;
}
