//-- In the name of ALLAH --
// We're nothing and you're everything.
// Ya Ali!
#include<bits/stdc++.h>
using namespace std;

#define      pai              acos(-1)
#define      ff               first
#define      ss               second
#define      ll               long long
#define      pb               push_back
#define      mp               make_pair
#define      pll              pair<ll,ll>
#define      sz(a)            (ll)a.size()
#define      endl             "\n"
#define      gcd(a, b)        __gcd(a, b)
#define      lcm(a, b)        ((a)*((b)/gcd(a,b))
#define      all(vec)         vec.begin(),vec.end()
#define      ms(a, b)         memset(a,b,sizeof(a))
#define      rep(i,n)         for(int i= 0; i < int(n); i++)
#define      rep1(i,n)        for(int i= 1; i <= n; i++)
#define      rev(i,n)         for(int i= (int)(n-1);i>=0;i--)
#define      rev1(i,n)        for(int i= (int) n;i>= 1;i--)
#define      TEST_CASE(t)     for(int zz=1;zz<=t;zz++)
#define      PRINT_CASE       printf("Case %d: ",zz)
#define      fii              freopen("input.txt","r",stdin);
#define      foo              freopen("output.txt","w",stdout);
#define      FAST             ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

const ll M   = 1e9+7;
const ll mxn = 2e5+7;


int  main()
{
    ll i,j,k,a,b,c,d,n,m,t,x,y,z,u,v;
    set<ll>st;
    for(i=0;i<=mxn;i++)
    {
        st.insert(i);
    }
    ll ans;
    map<ll,bool>vis;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>m;
        auto p = st.begin();
        if(*p!=m)
        {
            ans=*p;
            if(!vis[m]&&(st.find(m)!=st.end()))
            {
                st.erase(st.find(m));
                vis[m]=true;
            }
        }
        else
        {
            st.erase(st.begin());
            p = st.begin();
            ans=*p;
        }
        cout<<ans<<endl;
    }

    return 0;
}

/*------------------------------------
.......Bismillahir Rahmanir Rahim.....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <utility>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <functional>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x << '\n' 
#define   dbg(x)  cerr << #x << " = " << x << '\n' 
#define   bitcount(x)  (int)__builtin_popcount(x) 
#define   fast  ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0) 
#define   sz(x)  (int)x.size()
#define   all(a) a.begin(),a.end() 
#define   ff   first 
#define   ss   second 
#define   pi   acos(-1.0) 
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n; cin>>n; 
    map <int,int> c;
    int cur = 0 ; 
    while (n--){
        int x; cin >> x;
        c[x] = 1;
        while (c.count(cur)) cur++;
        co(cur);
    }
}

signed main()
{
    fast ; 
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}
