#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

template<typename T, typename E> class SegmentTree {
public:
  typedef function<T (T, T)> Operator;
  typedef function<T (T, E)> Apply;

  vector<T> data;
  ll n;
  T e;
  Operator op;
  Apply apply;

  SegmentTree(ll _n, T e, Operator op, Apply apply): e(e), op(op), apply(apply) {
    for(n = 1; n < _n; n *= 2);
    data.resize(n * 2 - 1, e);
  }

  T query(ll a, ll b) { return query(a, b, 0, 0, n); }
  T query(ll a, ll b, ll k, ll l, ll r) {
    if(r <= a || b <= l) return e;
    if(a <= l && r <= b) return data[k];
    T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return op(vl, vr);
  }

  void update(ll k, E x) {
    k += n - 1;
    data[k] = apply(data[k], x);
    while(k > 0) {
      k = (k - 1) / 2;
      data[k] = op(data[k * 2 + 1], data[k * 2 + 2]);
    }
  }
};

int main(void) {
  ll N;
  cin >> N;
  vector<ll> X(N);
  REP(i, 0, N) cin >> X[i];

  SegmentTree<ll, ll>::Operator op = [](ll a, ll b) { return a + b; };
  SegmentTree<ll, ll>::Apply apply = [](ll a, ll x) { return x; };
  SegmentTree<ll, ll> segtree(N * 2, 0, op, apply);

  REP(i, 0, N) {
    if(X[i] >= N * 2) {
      cout << "Yes" << endl;
    } else {
      if(segtree.query(0, 1) == 1) {
        cout << "No" << endl;
      } else if(segtree.query(X[i], X[i] + 1) == 1) {
        ll l = 0, h = X[i];
        while(h - l > 1) {
          ll m = (l + h) / 2;
          if(segtree.query(m, X[i] + 1) == X[i] - m + 1) h = m;
          else l = m;
        }

        if((l == 0 && segtree.query(X[i] + 1, N * 2) > 0)) {
          cout << "No" << endl;
        } else {
          cout << "Yes" << endl;
          segtree.update(l, 1);
          REP(j, l + 1, X[i] + 1) segtree.update(j, 0);
        }
      } else {
        cout << "Yes" << endl;
        segtree.update(X[i], 1);
      }
    }
  }
}

### Prompt

Develop a solution in CPP to the problem described below:

Example

Input

6
2
3
1
1
4
2


Output

Yes
Yes
Yes
No
Yes
No

### Response

```cpp
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

template<typename T, typename E> class SegmentTree {
public:
  typedef function<T (T, T)> Operator;
  typedef function<T (T, E)> Apply;

  vector<T> data;
  ll n;
  T e;
  Operator op;
  Apply apply;

  SegmentTree(ll _n, T e, Operator op, Apply apply): e(e), op(op), apply(apply) {
    for(n = 1; n < _n; n *= 2);
    data.resize(n * 2 - 1, e);
  }

  T query(ll a, ll b) { return query(a, b, 0, 0, n); }
  T query(ll a, ll b, ll k, ll l, ll r) {
    if(r <= a || b <= l) return e;
    if(a <= l && r <= b) return data[k];
    T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return op(vl, vr);
  }

  void update(ll k, E x) {
    k += n - 1;
    data[k] = apply(data[k], x);
    while(k > 0) {
      k = (k - 1) / 2;
      data[k] = op(data[k * 2 + 1], data[k * 2 + 2]);
    }
  }
};

int main(void) {
  ll N;
  cin >> N;
  vector<ll> X(N);
  REP(i, 0, N) cin >> X[i];

  SegmentTree<ll, ll>::Operator op = [](ll a, ll b) { return a + b; };
  SegmentTree<ll, ll>::Apply apply = [](ll a, ll x) { return x; };
  SegmentTree<ll, ll> segtree(N * 2, 0, op, apply);

  REP(i, 0, N) {
    if(X[i] >= N * 2) {
      cout << "Yes" << endl;
    } else {
      if(segtree.query(0, 1) == 1) {
        cout << "No" << endl;
      } else if(segtree.query(X[i], X[i] + 1) == 1) {
        ll l = 0, h = X[i];
        while(h - l > 1) {
          ll m = (l + h) / 2;
          if(segtree.query(m, X[i] + 1) == X[i] - m + 1) h = m;
          else l = m;
        }

        if((l == 0 && segtree.query(X[i] + 1, N * 2) > 0)) {
          cout << "No" << endl;
        } else {
          cout << "Yes" << endl;
          segtree.update(l, 1);
          REP(j, l + 1, X[i] + 1) segtree.update(j, 0);
        }
      } else {
        cout << "Yes" << endl;
        segtree.update(X[i], 1);
      }
    }
  }
}

```