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

int n;
const int MAX = 1000006;

class BIT {
  int n,bit[MAX+2];
public:
  BIT( int n = MAX ): n(n){
    fill( bit, bit + MAX+1, 0 );
  }

  void add(int i,int x){
    while( i <= n ) {
      bit[i] += x;
      i += i&-i;
    }
  }
  int sum(int i){
    int s = 0;
    while( i > 0 ){
      s += bit[i];
      i-= i&-i;
    }
    return s;
  }
};

BIT used;
void view(){
  for(int i=1;i<10;i++)
    cout << used.sum(i)-used.sum(i-1) <<" ";
  cout << endl;
}

int main(){
  cin >> n;  
  int cnt = 0;
  for(int i=0;i<n;i++){
    int x; cin >> x; x++;
    int t = x;
    if( used.sum(1) ) {
      cout << "No" << endl;
    } else if( x > 1000000 ) {
      cout << "Yes" << endl;
    } else if( used.sum(x) == x-1 && used.sum(MAX) > x-1 ) 
      cout << "No" << endl;
    else {      
      cout << "Yes" << endl;
      while( used.sum(x)-used.sum(x-1) ) used.add(x--,-1);
      used.add(x,1);
    }
    //view();
  }
}
### Prompt

Your challenge is to write 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<bits/stdc++.h>
using namespace std;

int n;
const int MAX = 1000006;

class BIT {
  int n,bit[MAX+2];
public:
  BIT( int n = MAX ): n(n){
    fill( bit, bit + MAX+1, 0 );
  }

  void add(int i,int x){
    while( i <= n ) {
      bit[i] += x;
      i += i&-i;
    }
  }
  int sum(int i){
    int s = 0;
    while( i > 0 ){
      s += bit[i];
      i-= i&-i;
    }
    return s;
  }
};

BIT used;
void view(){
  for(int i=1;i<10;i++)
    cout << used.sum(i)-used.sum(i-1) <<" ";
  cout << endl;
}

int main(){
  cin >> n;  
  int cnt = 0;
  for(int i=0;i<n;i++){
    int x; cin >> x; x++;
    int t = x;
    if( used.sum(1) ) {
      cout << "No" << endl;
    } else if( x > 1000000 ) {
      cout << "Yes" << endl;
    } else if( used.sum(x) == x-1 && used.sum(MAX) > x-1 ) 
      cout << "No" << endl;
    else {      
      cout << "Yes" << endl;
      while( used.sum(x)-used.sum(x-1) ) used.add(x--,-1);
      used.add(x,1);
    }
    //view();
  }
}
```