#include<bits/stdc++.h>
#define N 500005
using namespace std;

int A[N];

int main(){

  int n,x;
  cin>>n;

  int max1=0,min0=0;
  
  for(int i=0;i<n;i++){
    
    scanf("%d",&x);
    
    if(A[0]==1) printf("No\n");
    else if(x>=n+3) printf("Yes\n");
    else{

      if(min0>=x&&x<max1){
	printf("No\n");
	continue;
      }
      
      printf("Yes\n");

      int f=0;
      if(max1==x) f=1;
      
      A[x]++;
      
      while(A[x]==2){
	A[x]=0;
	A[--x]++;
      }
      
      if(f||max1<x) max1=x;
      	
      x=max(1,min0);
      
      while(A[x]==1){
	min0=x;
	x++;
      }
      
    }
    
  }
  
  return 0;
}
### Prompt

Please create a solution in Cpp to the following problem:

Example

Input

6
2
3
1
1
4
2


Output

Yes
Yes
Yes
No
Yes
No

### Response

```cpp
#include<bits/stdc++.h>
#define N 500005
using namespace std;

int A[N];

int main(){

  int n,x;
  cin>>n;

  int max1=0,min0=0;
  
  for(int i=0;i<n;i++){
    
    scanf("%d",&x);
    
    if(A[0]==1) printf("No\n");
    else if(x>=n+3) printf("Yes\n");
    else{

      if(min0>=x&&x<max1){
	printf("No\n");
	continue;
      }
      
      printf("Yes\n");

      int f=0;
      if(max1==x) f=1;
      
      A[x]++;
      
      while(A[x]==2){
	A[x]=0;
	A[--x]++;
      }
      
      if(f||max1<x) max1=x;
      	
      x=max(1,min0);
      
      while(A[x]==1){
	min0=x;
	x++;
      }
      
    }
    
  }
  
  return 0;
}
```