#include <cstdio>
#include <algorithm>
using namespace std;
int n, x, b[500029];
int main() {
	scanf("%d", &n);
	int r = 1, sum = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d", &x);
		if (b[0]) puts("No");
		else if (x >= 500020) puts("Yes");
		else {
			while (b[r]) r++;
			if (r <= x) {
				puts("Yes");
				int z = x; b[z]++, sum++;
				while (b[z] == 2) b[z] = 0, b[--z]++, sum--;
				r = min(r, z + 1);
			}
			else {
				if (sum == x) puts("Yes"), b[0] = 1;
				else puts("No");
			}
		}
	}
	return 0;
}
### 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 <cstdio>
#include <algorithm>
using namespace std;
int n, x, b[500029];
int main() {
	scanf("%d", &n);
	int r = 1, sum = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d", &x);
		if (b[0]) puts("No");
		else if (x >= 500020) puts("Yes");
		else {
			while (b[r]) r++;
			if (r <= x) {
				puts("Yes");
				int z = x; b[z]++, sum++;
				while (b[z] == 2) b[z] = 0, b[--z]++, sum--;
				r = min(r, z + 1);
			}
			else {
				if (sum == x) puts("Yes"), b[0] = 1;
				else puts("No");
			}
		}
	}
	return 0;
}
```