#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for(int i=s;i<e;i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(),(a).end()
typedef long long LL;
const LL mod = 1000000007;
int cnta[4444][26],cntb[4444][26];
string st[4444][26];
string u="abcdefghijklmnopqrstuvwxyz";

int dp[505050];
int bt = 0;
int m = 0;
int main(){
    int n;
    cin >> n;
    REP(i, n){
        int x;
        cin >> x;
        if(bt == -1){
            puts("No");
            continue;
        }
        if(x > 500000){
            m = 505050;
            puts("Yes");
            continue;
        }
        if(x < bt) puts("No");
        else if(x == bt){
            if(m == x){
                puts("Yes");
                bt = -1;
            }else{
                puts("No");
            }
        }
        else{
            puts("Yes");
            dp[x]++;
            if(x > m) m = x;
            while(dp[x] == 2){
                dp[x] = 0;
                if(x == m) m--;
                dp[--x]++;
            }
            while(dp[bt+1]) bt++;
        }

    }

}


### Prompt

Generate a CPP solution to the following problem:

Example

Input

6
2
3
1
1
4
2


Output

Yes
Yes
Yes
No
Yes
No

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for(int i=s;i<e;i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(),(a).end()
typedef long long LL;
const LL mod = 1000000007;
int cnta[4444][26],cntb[4444][26];
string st[4444][26];
string u="abcdefghijklmnopqrstuvwxyz";

int dp[505050];
int bt = 0;
int m = 0;
int main(){
    int n;
    cin >> n;
    REP(i, n){
        int x;
        cin >> x;
        if(bt == -1){
            puts("No");
            continue;
        }
        if(x > 500000){
            m = 505050;
            puts("Yes");
            continue;
        }
        if(x < bt) puts("No");
        else if(x == bt){
            if(m == x){
                puts("Yes");
                bt = -1;
            }else{
                puts("No");
            }
        }
        else{
            puts("Yes");
            dp[x]++;
            if(x > m) m = x;
            while(dp[x] == 2){
                dp[x] = 0;
                if(x == m) m--;
                dp[--x]++;
            }
            while(dp[bt+1]) bt++;
        }

    }

}


```