#include <bits/stdc++.h>
using namespace std;

int main() {
	
	//we have to find the maximum lexicographic mex first come sthe 
	//greater element 
	//if both are qual then come s the size
	
	
	///first we have to precompute the suffix me xfor each element so that we can 
	//do the proplem properly
	
	int n;
	cin>>n;
	
	vector<int>nums(n);
	
	for(int i=0;i<n;i++){
		cin>>nums[i];
	}
	vector<bool>seen(n+1,false);
	vector<int>suff(n);
	int cur=0;
	for(int i=n-1;i>=0;i--){
		
		if(nums[i]<=n)seen[nums[i]]=true;
		
	    while(seen[cur]){
	    	cur++;
	    }
	    
		suff[i]=cur;
	}
	
	vector<int>ans;
	//now e ahev to move from the front of the arary calculating 
	//like first max is suff[0] and we have to find the lasrgest val where it apperas like suff[0]
	
	int i=0;
	vector<int>found(n+1,0);
	int timer=1;
	while(i<n){
		int maxi=suff[i];
		
		int cur=0;
		while(i<n&&cur!=maxi){
			if(nums[i]<=n)found[nums[i]]=timer;
			
			while(found[cur]==timer){
				cur++;
			}
			i++;
		}
		timer++;
		ans.push_back(maxi);
	}
	
	for(int i=0;i<ans.size();i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}