#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 600000


int table[NUM];

int main(){

	for(int i = 0; i < NUM; i++)table[i] = 0;

	int N;
	scanf("%d",&N);

	int head_0_pos = 1,under_0_num = 0,minus,tmp_pos,tmp;

	for(int loop = 0; loop < N; loop++){
		scanf("%d",&tmp);

		if(table[0] == 1){
			printf("No\n");
			continue;
		}

		if(tmp >= NUM){
			printf("Yes\n");
			continue;
		}

		if(tmp < head_0_pos){

			if(tmp < head_0_pos-1 || under_0_num > 0){
				printf("No\n");
			}else{
				printf("Yes\n");
				table[0] = 1;
			}

		}else if(tmp == head_0_pos){

			printf("Yes\n");

			table[head_0_pos] = 1;

			minus = 0;

			head_0_pos++;
			while(table[head_0_pos] == 1){
				minus++;
				head_0_pos++;
			}

			under_0_num -= minus;

		}else{

			printf("Yes\n");

			tmp_pos = tmp;
			table[tmp_pos]++;

			while(table[tmp_pos] == 2){
				table[tmp_pos] = 0;
				table[tmp_pos-1]++;
				tmp_pos -= 1;
			}

			if(tmp_pos == head_0_pos){

				head_0_pos += 1;
				under_0_num -= (tmp-tmp_pos);

			}else{

				under_0_num++;
				under_0_num -= (tmp-tmp_pos);
			}
		}
	}

	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 <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 600000


int table[NUM];

int main(){

	for(int i = 0; i < NUM; i++)table[i] = 0;

	int N;
	scanf("%d",&N);

	int head_0_pos = 1,under_0_num = 0,minus,tmp_pos,tmp;

	for(int loop = 0; loop < N; loop++){
		scanf("%d",&tmp);

		if(table[0] == 1){
			printf("No\n");
			continue;
		}

		if(tmp >= NUM){
			printf("Yes\n");
			continue;
		}

		if(tmp < head_0_pos){

			if(tmp < head_0_pos-1 || under_0_num > 0){
				printf("No\n");
			}else{
				printf("Yes\n");
				table[0] = 1;
			}

		}else if(tmp == head_0_pos){

			printf("Yes\n");

			table[head_0_pos] = 1;

			minus = 0;

			head_0_pos++;
			while(table[head_0_pos] == 1){
				minus++;
				head_0_pos++;
			}

			under_0_num -= minus;

		}else{

			printf("Yes\n");

			tmp_pos = tmp;
			table[tmp_pos]++;

			while(table[tmp_pos] == 2){
				table[tmp_pos] = 0;
				table[tmp_pos-1]++;
				tmp_pos -= 1;
			}

			if(tmp_pos == head_0_pos){

				head_0_pos += 1;
				under_0_num -= (tmp-tmp_pos);

			}else{

				under_0_num++;
				under_0_num -= (tmp-tmp_pos);
			}
		}
	}

	return 0;
}


```