#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
	int n;
	set<int> k;
	cin>>n;
	int p[n+1];
	for(int i=1;i<=n;i++){
		cin>>p[i];
	}
	for(int i=0;i<=200005;i++){
		k.insert(i);
	}
	for(int i=1;i<=n;i++){
		if(k.find(p[i])!=k.end()){
			k.erase(k.find(p[i]));
		}
		set<int>::iterator ite;
		ite=k.begin();
		cout<<*ite<<endl;
	}

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using pii = pair<int,int>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back

int main() {
  int N; cin>>N;
  vi cnt(200005,0),p(N);
  vi ans;
  rep(i,N) {
    cin>>p[i];
    cnt[p[i]]++;
  }
  int min;
  rep(i,200005) {
    if(cnt[i]==0) {
      min=i;
      break;
    }
  }

  for(int i=N-1;i>=0;i--) {
    ans.pb(min);
    cnt[p[i]]--;
    if(cnt[p[i]]==0&&p[i]<min) min=p[i];
  }
  for(int i=N-1;i>=0;i--) cout<<ans[i]<<endl;
}
