#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>
#include <functional>
#include <bitset>
#include <cstdlib>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define fastio ios::sync_with_stdio(0), cin.tie(0)
#define PI 3.1415926535897932
const ll mod = 1000000007;
const int INF = 2123456789;
const double eps = 1e-7;

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}
const int maxn = 501000;
int now[maxn];

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int n;
    scanf("%d", &n);
    int dep = 0, top = 0;
    bool full = false;
    for(int i = 0; i < n; i++){
        int x;
        scanf("%d", &x);
        if(x >= maxn){
            printf("Yes\n");
            continue;
        }
        else if(full){
            printf("No\n");
            continue;
        }
        else{
            if(x < top){
                printf("No\n");
                continue;
            }
            else if(x == top && dep != top){
                printf("No\n");
                continue;
            }
            else{
                printf("Yes\n");
                dep = max(dep, x);
                now[x]++;
                while(now[x] >= 2){
                    now[x] = 0;
                    if(dep == x)dep--;
                    x--;
                    now[x]++;
                    if(x == 0){
                        full = 1;
                        break;
                    }
                }
                for(int i = top + 1; now[i] == 1; i++){
                    top = i;
                }
            }
        }
    }
    return 0;
}
### Prompt

Construct a cpp code solution to the problem outlined:

Example

Input

6
2
3
1
1
4
2


Output

Yes
Yes
Yes
No
Yes
No

### Response

```cpp
#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>
#include <functional>
#include <bitset>
#include <cstdlib>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define fastio ios::sync_with_stdio(0), cin.tie(0)
#define PI 3.1415926535897932
const ll mod = 1000000007;
const int INF = 2123456789;
const double eps = 1e-7;

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}
const int maxn = 501000;
int now[maxn];

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int n;
    scanf("%d", &n);
    int dep = 0, top = 0;
    bool full = false;
    for(int i = 0; i < n; i++){
        int x;
        scanf("%d", &x);
        if(x >= maxn){
            printf("Yes\n");
            continue;
        }
        else if(full){
            printf("No\n");
            continue;
        }
        else{
            if(x < top){
                printf("No\n");
                continue;
            }
            else if(x == top && dep != top){
                printf("No\n");
                continue;
            }
            else{
                printf("Yes\n");
                dep = max(dep, x);
                now[x]++;
                while(now[x] >= 2){
                    now[x] = 0;
                    if(dep == x)dep--;
                    x--;
                    now[x]++;
                    if(x == 0){
                        full = 1;
                        break;
                    }
                }
                for(int i = top + 1; now[i] == 1; i++){
                    top = i;
                }
            }
        }
    }
    return 0;
}
```