#include "bits/stdc++.h"
using namespace std;
int b[500000], p = 1, cnt = 0;
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if (b[0] == 1 || x < p - 1) {
			cout << "No" << endl;
			continue;
		}
		if (p - 1 == x && cnt > x) {
			cout << "No" << endl;
			continue;
		}
		cnt++;
		cout << "Yes" << endl;
		if (x >= n) continue;
		b[x]++;
		while (x > 0 && b[x] >= 2) b[x] -= 2, b[x - 1]++, x--, cnt--;
		while (p < n && b[p] == 1) p++;
	}
}

### 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;
int b[500000], p = 1, cnt = 0;
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if (b[0] == 1 || x < p - 1) {
			cout << "No" << endl;
			continue;
		}
		if (p - 1 == x && cnt > x) {
			cout << "No" << endl;
			continue;
		}
		cnt++;
		cout << "Yes" << endl;
		if (x >= n) continue;
		b[x]++;
		while (x > 0 && b[x] >= 2) b[x] -= 2, b[x - 1]++, x--, cnt--;
		while (p < n && b[p] == 1) p++;
	}
}

```