#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
int f[510000];
int c[510000];
void add(int x,int y)
{
	for (;x <= 500010;x+=x&(-x))
		c[x] += y;
}
int find(int x)
{
	int res = 0;
	for (;x;x-=x&(-x))
		res += c[x];
	return res;
}
int n;
int judge(int x)
{
	if (f[x]) {f[x]--; add(x,-1);return 1;}
	if (find(x-1) == 0) return 0;
	
	int i;
	for (i = x-1;i >= 0;i--)
		if (f[i])
			break;
//	cout << i << endl;
	f[i]--; add(i,-1);
	for (i=i+1;i <= x;i++)
		f[i]++,add(i,1);
	return 1;
}
int main()
{
	cin >> n;
	add(1,2);
	f[1] = 2;
	for (int i = 1;i <= n;i++)
	{
		int x;scanf("%d",&x);
		x = min(x,500005);
		if (judge(x))
			printf("Yes\n");
		else 
			printf("No\n");
	}
}
### Prompt

Generate 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 <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
int f[510000];
int c[510000];
void add(int x,int y)
{
	for (;x <= 500010;x+=x&(-x))
		c[x] += y;
}
int find(int x)
{
	int res = 0;
	for (;x;x-=x&(-x))
		res += c[x];
	return res;
}
int n;
int judge(int x)
{
	if (f[x]) {f[x]--; add(x,-1);return 1;}
	if (find(x-1) == 0) return 0;
	
	int i;
	for (i = x-1;i >= 0;i--)
		if (f[i])
			break;
//	cout << i << endl;
	f[i]--; add(i,-1);
	for (i=i+1;i <= x;i++)
		f[i]++,add(i,1);
	return 1;
}
int main()
{
	cin >> n;
	add(1,2);
	f[1] = 2;
	for (int i = 1;i <= n;i++)
	{
		int x;scanf("%d",&x);
		x = min(x,500005);
		if (judge(x))
			printf("Yes\n");
		else 
			printf("No\n");
	}
}
```