#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> v(500010);
    int h = 1, cnt = 0;
    for(int i=0; i<n; ++i) {
        int x; cin >> x;
        if(v[0]) {
            cout << "No" << endl;
        } else if(x >= v.size()-1) {
            cout << "Yes" << endl;
        } else {
            while(v[h]) {
                h++;
            }
            if(h <= x) {
                cout << "Yes" << endl;
                int now = x;
                v[now]++;
                cnt++;
                while(v[now] == 2) {
                    v[now] = 0;
                    now -= 1;
                    v[now]++;
                    cnt--;
                }
                h = min(h, now+1);
            } else {
                if(x == cnt) {
                    cout << "Yes" << endl;
                    v[0] = 1;
                } else {
                    cout << "No" << endl;
                }
            }
        }
    }
}

### Prompt

Create a solution in CPP for 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;

int main() {
    int n;
    cin >> n;
    vector<int> v(500010);
    int h = 1, cnt = 0;
    for(int i=0; i<n; ++i) {
        int x; cin >> x;
        if(v[0]) {
            cout << "No" << endl;
        } else if(x >= v.size()-1) {
            cout << "Yes" << endl;
        } else {
            while(v[h]) {
                h++;
            }
            if(h <= x) {
                cout << "Yes" << endl;
                int now = x;
                v[now]++;
                cnt++;
                while(v[now] == 2) {
                    v[now] = 0;
                    now -= 1;
                    v[now]++;
                    cnt--;
                }
                h = min(h, now+1);
            } else {
                if(x == cnt) {
                    cout << "Yes" << endl;
                    v[0] = 1;
                } else {
                    cout << "No" << endl;
                }
            }
        }
    }
}

```