//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
//using Graph = vector<vector<int>>;
typedef long long ll;
using Graph = vector<vector<pair<ll,ll>>>;
const int mod =1e+9+7;

const int dy[4]={0,1,0,-1};
const int dx[4]={1,0,-1,0};
const ll INF=1e10;

int main(){
    ll n; cin>>n;
    vector<ll>a(n);
        map<ll,ll>mp;
    rep(i,n){
        cin>>a[i];
        mp[a[i]]++;
    }

    vector<bool>f(200010,true);
    rep(i,n){
        f[a[i]]=false;
    }
    ll maxdiff=0;
    rep(i,n+1){
        if(f[i]==true){
            maxdiff=i;
            break;
        }
    }
    vector<ll>ans(n);
    ans[0]=maxdiff;
    for(int i=1;i<n;i++){
        if(a[n-i]>=maxdiff){
            ans[i]=maxdiff;
        }
        else{
            if(mp[a[n-i]]==1){
                ans[i]=a[n-i];
                maxdiff=a[n-i];
                mp[a[n-i]]--;
            }
            else{
                mp[a[n-i]]--;
                ans[i]=maxdiff;
            }
        }
    }
    reverse(all(ans));
    rep(i,n){
        cout<<ans[i]<<endl;
    }

}









#include <iostream>
#include <cstring>
#include <cstdio>
#define LL long long
#define maxn 210005

using namespace std;

int n,a[maxn];
bool vis[maxn];

int main()
{
    memset(vis,0,sizeof(vis));
    scanf("%d",&n);
    for (int i=0;i<n;i++) scanf("%d",&a[i]);
    int now=0;
    for (int i=0;i<n;i++)
    {
        vis[a[i]]=1;
        while (vis[now]) now++;
        printf("%d\n",now);
    }
    return 0;
}
