#include "bits/stdc++.h"

using namespace std;

// add(pos, n): data[pos] += n;
// sum(l, r)  : sum [l, r)
template <typename T>
class FenwickTree
{
    const int n;
    vector<T> data;

  public:
    FenwickTree(int _n) : n(_n), data(_n, 0) {}

    void add(int pos, const T &value)
    {
        for (int i = pos; i < n; i |= i + 1)
            data[i] += value;
    }

    T sum(int pos) const
    {
        T res = 0;
        for (int i = pos - 1; i >= 0; i = (i & (i + 1)) - 1)
            res += data[i];
        return res;
    }

    T sum(int l, int r) const
    {
        return sum(r) + (-sum(l));
    }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    FenwickTree<int> ft(N + 1);
    int cnt = 0;
    bool zero = false;
    vector<int> x(N);
    for (int i = 0; i < N; i++)
    {
        cin >> x[i];
        bool f;
        if (zero)
        {
            f = false;
        }
        else if (N < x[i])
        {
            cnt++;
            f = true;
        }
        else if (!ft.sum(x[i], x[i] + 1))
        {
            f = true;
            ft.add(x[i], 1);
        }
        else
        {
            if (ft.sum(1, x[i] + 1) == x[i] && (cnt || ft.sum(x[i] + 1, N + 1)))
            {
                f = false;
            }
            else
            {
                f = true;
                while (ft.sum(x[i], x[i] + 1))
                {
                    ft.add(x[i], -1);
                    x[i]--;
                }
                ft.add(x[i], 1);
                if (x[i] == 0)
                    zero = true;
            }
        }
        cout << (f ? "Yes" : "No") << endl;
    }
    return 0;
}


### Prompt

Please provide a CPP coded solution 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"

using namespace std;

// add(pos, n): data[pos] += n;
// sum(l, r)  : sum [l, r)
template <typename T>
class FenwickTree
{
    const int n;
    vector<T> data;

  public:
    FenwickTree(int _n) : n(_n), data(_n, 0) {}

    void add(int pos, const T &value)
    {
        for (int i = pos; i < n; i |= i + 1)
            data[i] += value;
    }

    T sum(int pos) const
    {
        T res = 0;
        for (int i = pos - 1; i >= 0; i = (i & (i + 1)) - 1)
            res += data[i];
        return res;
    }

    T sum(int l, int r) const
    {
        return sum(r) + (-sum(l));
    }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    FenwickTree<int> ft(N + 1);
    int cnt = 0;
    bool zero = false;
    vector<int> x(N);
    for (int i = 0; i < N; i++)
    {
        cin >> x[i];
        bool f;
        if (zero)
        {
            f = false;
        }
        else if (N < x[i])
        {
            cnt++;
            f = true;
        }
        else if (!ft.sum(x[i], x[i] + 1))
        {
            f = true;
            ft.add(x[i], 1);
        }
        else
        {
            if (ft.sum(1, x[i] + 1) == x[i] && (cnt || ft.sum(x[i] + 1, N + 1)))
            {
                f = false;
            }
            else
            {
                f = true;
                while (ft.sum(x[i], x[i] + 1))
                {
                    ft.add(x[i], -1);
                    x[i]--;
                }
                ft.add(x[i], 1);
                if (x[i] == 0)
                    zero = true;
            }
        }
        cout << (f ? "Yes" : "No") << endl;
    }
    return 0;
}


```