#include<bits/stdc++.h>
using namespace std;
#define ll               long long
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fi                 first
#define sc                second
#define pii              pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define fl fflush(stdout)
//#define mod 1000000007
#define mod2 998244353
#define pi 3.14159265358979323846
//bool comp(const pair<int,double> &a,const pair<int,double> &b){  return (a.second > b.second);  }
/*
bool prime[111111];
bool isPrime(int n)
{
    for(int i=2;i*i<=n;++i)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
bool prime[100005];
void sieve(int n)
{
    memset(prime,true,sizeof(prime));
    prime[1]=false;
    for (int p=2;p*p<=n;p++)
    {
        if (prime[p]==true)
        {
            for (int i=p*p;i<=n;i+=p)prime[i]=false;
        }
    }
}
void dfs(int p){
    used[p]=true;
    rep(i,n){
        if(used[i]==true) continue;
        if(X[i]==X[p] || Y[i]==Y[p])dfs(i);
    }
}
void bfs(int s) {
    d = vector<int>(n, INF);  d[s] = 0;
    queue<int> q;
    q.push(s);
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (auto to : g[v]) {  if (d[to] == INF) {  d[to] = d[v] + 1;  q.push(to); } }
    }
}
void update(int x, ll val){while(x <= n)tree[x] += val,x += (x & -x);}
ll read(int x){ ll sum=0; while (x>0)sum+=tree[x],x -= (x & -x); return sum;}
void update(int l, int r, int nod, int lvl)
{
      if(l==r)tree[nod] = x;
      else
        {
            int mid = (l+r)/2; //left tree
            if(i <= mid) update(l,mid,nod*2,lvl-1);//right tree
            else update(mid+1,r,nod*2+1,lvl-1);
            if(lvl%2 == 0) tree[nod] = (tree[2*nod]^tree[nod*2 + 1]);
            else tree[nod] = (tree[2*nod]|tree[nod*2 + 1]);
        }
}
bool sortbysec(const pair<int,int> &a , const pair<int,int> &b) {
    if(a.first==b.first) {return(a.second < b.second);}
    else return a.first<b.first;
    }
while(n>0)
    {
        if(n&1)ans=(ans*x)%mo;
         n/=2;
          x =(x*x)%mo;
    }

bool sortbysec(const pair<int,int> &a , const pair<int,int> &b) {
     return a.second<b.second;//
    }
#define max 60
ll dp[25][25];
ll nCr(ll n, ll r)
{
       if(n==r) return dp[n][r] = 1; 
       if(r==0) return dp[n][r] = 1; 
       if(r==1) return dp[n][r] = n;
       if(dp[n][r]) return dp[n][r]; 
       return dp[n][r] = (nCr(n-1,r) + nCr(n-1,r-1));
}
*/
void solve(){
    //points to remember:
    //1.overflow 2.max/min values 3.array bound 4.special case(n==1) 5.infinite loop
    int n; cin>>n;
    vector<int> v(n);
    rep(i,0,n)cin>>v[i];
    int mex=0;
    set<int> s,p;
    rep(i,0,200001)p.insert(i);
    rep(i,0,n){
        p.erase(v[i]);
        if(v[i]==mex)mex=*p.begin();
        cout<<mex<<"\n";
    }
}
int main(){
    //ios_base::sync_with_stdio(false);  cin.tie(0);cout.tie(0);
    //sieve(100000);
    //int t; cin>>t; while(t--)
    solve();
}
#include <iostream>
#include <cstring>
using namespace std;
typedef long long ll;
ll f(ll x){
	return (x+1)*x/2;
}
int main(){
	ll l=1,r=100000;
	ll n;
	cin >> n;
	while(l<r){
		ll mid=(l+r)/2;
		if(f(mid)<n)
			l=mid+1;
		else
			r=mid;
	}
	cout << l << endl;
	return 0;
}