#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

set<int> st;
int mx = 0;
bool over = 0;

void solve() {
    int n;
    cin >> n;
    REP(i,n) {
        int num;
        cin >> num;
        // cout << mx << endl;
        if (over) {
            cout << "No" << endl;
            continue;
        }
        if (num < mx) {
            cout << "No" << endl;
            continue;
        }
        if (num == mx) {
            if (st.size() != mx) {
                cout << "No" << endl;
                continue;
            }
            over = 1;
            cout << "Yes" << endl;
            continue;
        }
        if (num == mx + 1) {
            mx++;
            st.insert(num);
// cout << "insert " << num << endl;
            cout << "Yes" << endl;
            while (st.count(mx + 1)) {
                mx++;
            }
            continue;
        }
        cout << "Yes" << endl;
        int tmp = num;
        while (st.count(tmp)) {
            tmp--;
        }
        for (int i = tmp + 1; i <= num; i++) {
            st.erase(i);
// cout << "erase " << i << endl;
        }
        st.insert(tmp);
// cout << "insert " << tmp << endl;
        if (tmp == mx + 1) {
            mx++;
            while (st.count(mx+1)) mx++;
        }
    }
}

int main(int argc, char *argv[]){
    // /* Regular */
    // int case_num = 1;
    // if (argc > 1 && stoi(argv[1])) cin >> case_num;
    // REP(case_no, case_num) {
    //   cerr << endl << "case " << case_no + 1 << endl;
    //   solve();
    // }
    /* AOJ */
    solve();
    return 0;
}

### Prompt

Please create a solution in Cpp 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;
using ll = long long;
using ull = unsigned long long;
constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

set<int> st;
int mx = 0;
bool over = 0;

void solve() {
    int n;
    cin >> n;
    REP(i,n) {
        int num;
        cin >> num;
        // cout << mx << endl;
        if (over) {
            cout << "No" << endl;
            continue;
        }
        if (num < mx) {
            cout << "No" << endl;
            continue;
        }
        if (num == mx) {
            if (st.size() != mx) {
                cout << "No" << endl;
                continue;
            }
            over = 1;
            cout << "Yes" << endl;
            continue;
        }
        if (num == mx + 1) {
            mx++;
            st.insert(num);
// cout << "insert " << num << endl;
            cout << "Yes" << endl;
            while (st.count(mx + 1)) {
                mx++;
            }
            continue;
        }
        cout << "Yes" << endl;
        int tmp = num;
        while (st.count(tmp)) {
            tmp--;
        }
        for (int i = tmp + 1; i <= num; i++) {
            st.erase(i);
// cout << "erase " << i << endl;
        }
        st.insert(tmp);
// cout << "insert " << tmp << endl;
        if (tmp == mx + 1) {
            mx++;
            while (st.count(mx+1)) mx++;
        }
    }
}

int main(int argc, char *argv[]){
    // /* Regular */
    // int case_num = 1;
    // if (argc > 1 && stoi(argv[1])) cin >> case_num;
    // REP(case_no, case_num) {
    //   cerr << endl << "case " << case_no + 1 << endl;
    //   solve();
    // }
    /* AOJ */
    solve();
    return 0;
}

```