#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int mp[500010];
int cant,snum,si,cou;
bool par = true;

int main()
{
	int n;cin >> n;
	
	REP(a,n)
	{
		int tmp;
		cin >> tmp;
		
		if(!par)
		{
			cout << "No" << endl;
			continue;
		}
		
		if(tmp > 500000)
		{
			cout << "Yes" << endl;
			cou++;
			continue;
		}
		
		if(tmp <= cant || tmp <= si)
		{
			cout << "No" << endl;
			continue;
		}
		
		mp[tmp]++;
		
		bool ok = true;
		bool tmpp = true;
		int ssi = 0,ssnum = 0;
		for(ll i=si+1,k=2,num=snum;i<500001;i++)
		{
			k -= mp[i];num+=mp[i];
			if(k < 0)
			{
				ok = false;
				break;
			}
			if(k == 0)
			{
				tmpp = false;
			}
			if(k == 1 && num < cou)
			{
				ssi = max(si,(int)i);
				ssnum = num;
			}
			if(k > 500000)
			{
				break;
			}
			k *= 2;
		}
		if(ok)
		{
			cout << "Yes" << endl;
			cou++;
			par &= tmpp;
			si = max(si,ssi);
			snum = max(snum,ssnum);
		}
		else
		{
			cout << "No" << endl;
			mp[tmp]--;
			cant = max(cant,tmp);
		}
		//cout << si << ' ' << snum << endl;
	}
			
			
	
	
	return 0;
}
### Prompt

Construct a CPP code solution to the problem outlined:

Example

Input

6
2
3
1
1
4
2


Output

Yes
Yes
Yes
No
Yes
No

### Response

```cpp
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int mp[500010];
int cant,snum,si,cou;
bool par = true;

int main()
{
	int n;cin >> n;
	
	REP(a,n)
	{
		int tmp;
		cin >> tmp;
		
		if(!par)
		{
			cout << "No" << endl;
			continue;
		}
		
		if(tmp > 500000)
		{
			cout << "Yes" << endl;
			cou++;
			continue;
		}
		
		if(tmp <= cant || tmp <= si)
		{
			cout << "No" << endl;
			continue;
		}
		
		mp[tmp]++;
		
		bool ok = true;
		bool tmpp = true;
		int ssi = 0,ssnum = 0;
		for(ll i=si+1,k=2,num=snum;i<500001;i++)
		{
			k -= mp[i];num+=mp[i];
			if(k < 0)
			{
				ok = false;
				break;
			}
			if(k == 0)
			{
				tmpp = false;
			}
			if(k == 1 && num < cou)
			{
				ssi = max(si,(int)i);
				ssnum = num;
			}
			if(k > 500000)
			{
				break;
			}
			k *= 2;
		}
		if(ok)
		{
			cout << "Yes" << endl;
			cou++;
			par &= tmpp;
			si = max(si,ssi);
			snum = max(snum,ssnum);
		}
		else
		{
			cout << "No" << endl;
			mp[tmp]--;
			cant = max(cant,tmp);
		}
		//cout << si << ' ' << snum << endl;
	}
			
			
	
	
	return 0;
}
```