#include <iostream>
#include <bitset>

using namespace std;
constexpr int MAX = 600000;
bitset<MAX> Mask;
int LSB = 0;
int MSB = MAX - 1;
bool place(const int d)
{
    if (d > MAX) {
        return not Mask.all();
    } else {
        const int bit = MAX - d;
        if (MSB < bit) {
            return false;
        } else {
            int pos = bit;
            while (Mask[pos]) {
                Mask[pos] = 0;
                pos++;
            }
            Mask[pos] = 1;
            if (pos == MSB) {
                while (pos >= 0 and Mask[pos]) {
                    pos--;
                }
                MSB = pos;
            }
            return true;
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    bool first = true;
    for (int i = 0; i < N; i++) {
        int d;
        cin >> d;
        if (first) {
            cout << "Yes" << endl;
            for (int i = d + 1; i < MAX; i++) {
                place(i);
            }
            first = false;
        } else {
            cout << (place(d) ? "Yes" : "No") << endl;
        }
    }

    return 0;
}


### Prompt

Your challenge is to write a cpp solution to the following problem:

Example

Input

6
2
3
1
1
4
2


Output

Yes
Yes
Yes
No
Yes
No

### Response

```cpp
#include <iostream>
#include <bitset>

using namespace std;
constexpr int MAX = 600000;
bitset<MAX> Mask;
int LSB = 0;
int MSB = MAX - 1;
bool place(const int d)
{
    if (d > MAX) {
        return not Mask.all();
    } else {
        const int bit = MAX - d;
        if (MSB < bit) {
            return false;
        } else {
            int pos = bit;
            while (Mask[pos]) {
                Mask[pos] = 0;
                pos++;
            }
            Mask[pos] = 1;
            if (pos == MSB) {
                while (pos >= 0 and Mask[pos]) {
                    pos--;
                }
                MSB = pos;
            }
            return true;
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    bool first = true;
    for (int i = 0; i < N; i++) {
        int d;
        cin >> d;
        if (first) {
            cout << "Yes" << endl;
            for (int i = d + 1; i < MAX; i++) {
                place(i);
            }
            first = false;
        } else {
            cout << (place(d) ? "Yes" : "No") << endl;
        }
    }

    return 0;
}


```