#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = a; i < n; ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int n;
int x[500010];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n;
    REP(i, n) cin >> x[i];
    int z = 1;
    set<int> st;
    REP(i, n) {
        if (st.count(0) || x[i] < z - 1) {
            cout << "No" << endl;
            continue;
        }
        if (x[i] == z - 1 && st.size() != z - 1) {
            cout << "No" << endl;
            continue;
        }
        cout << "Yes" << endl;
        int cur = x[i];
        while (st.count(cur)) {
            st.erase(cur);
            --cur;
        }
        st.insert(cur);
        while (st.count(z)) ++z;
    }
}

### 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>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = a; i < n; ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int n;
int x[500010];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n;
    REP(i, n) cin >> x[i];
    int z = 1;
    set<int> st;
    REP(i, n) {
        if (st.count(0) || x[i] < z - 1) {
            cout << "No" << endl;
            continue;
        }
        if (x[i] == z - 1 && st.size() != z - 1) {
            cout << "No" << endl;
            continue;
        }
        cout << "Yes" << endl;
        int cur = x[i];
        while (st.count(cur)) {
            st.erase(cur);
            --cur;
        }
        st.insert(cur);
        while (st.count(z)) ++z;
    }
}

```