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

template <class T>
struct BIT{
	int n;
	vector<T> x;
	BIT(int n_ = 0) : n(n_), x(n + 1, 0){}
	int size() const{ return n; }
	T sum(int r) const{
		T S = 0;
		for(r = r - 1; r >= 0; r = (r & (r + 1)) - 1) S += x[r];
		return S;
	}
	T sum(int l, int r) const{ return sum(r) - sum(l); }
	void add(int k, const T &a){
		for(; k < n; k |= k + 1) x[k] += a;
	}
	void set(int k, const T &a){ add(k, a - sum(k, k + 1)); }
	int lower_bound(T x){
		int ng = -1, ok = n - 1;
		while(abs(ng - ok) > 1){
			int mid = (ng + ok) / 2;
			if(sum(0, mid + 1) >= x) ok = mid;
			else ng = mid;
		}
		return ok;
	}
};

const int MAX_N = 1000000;
BIT<ll> bit(MAX_N);

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int n;
	cin >> n;

	set<int> s;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;

		bool yes = false;
		if(s.count(0)){
			yes = false;
		}
		else if(s.count(x) == 0){
			s.insert(x);
			if(x < MAX_N) bit.add(x, 1);
			yes = true;
		}
		else{
			if(x < MAX_N && bit.sum(1, x) == x - 1 && s.upper_bound(x) != s.end()){
				yes = false;
			}
			else{
				yes = true;
				// ??£???
				while(s.count(x)){
					s.erase(x);
					if(x < MAX_N) bit.add(x, -1);
					x--;
				}
				s.insert(x);
				if(x < MAX_N) bit.add(x, 1);
			}
		}
		if(yes) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}
### Prompt

Develop a solution in cpp to the problem described below:

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;
typedef long long ll;

template <class T>
struct BIT{
	int n;
	vector<T> x;
	BIT(int n_ = 0) : n(n_), x(n + 1, 0){}
	int size() const{ return n; }
	T sum(int r) const{
		T S = 0;
		for(r = r - 1; r >= 0; r = (r & (r + 1)) - 1) S += x[r];
		return S;
	}
	T sum(int l, int r) const{ return sum(r) - sum(l); }
	void add(int k, const T &a){
		for(; k < n; k |= k + 1) x[k] += a;
	}
	void set(int k, const T &a){ add(k, a - sum(k, k + 1)); }
	int lower_bound(T x){
		int ng = -1, ok = n - 1;
		while(abs(ng - ok) > 1){
			int mid = (ng + ok) / 2;
			if(sum(0, mid + 1) >= x) ok = mid;
			else ng = mid;
		}
		return ok;
	}
};

const int MAX_N = 1000000;
BIT<ll> bit(MAX_N);

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int n;
	cin >> n;

	set<int> s;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;

		bool yes = false;
		if(s.count(0)){
			yes = false;
		}
		else if(s.count(x) == 0){
			s.insert(x);
			if(x < MAX_N) bit.add(x, 1);
			yes = true;
		}
		else{
			if(x < MAX_N && bit.sum(1, x) == x - 1 && s.upper_bound(x) != s.end()){
				yes = false;
			}
			else{
				yes = true;
				// ??£???
				while(s.count(x)){
					s.erase(x);
					if(x < MAX_N) bit.add(x, -1);
					x--;
				}
				s.insert(x);
				if(x < MAX_N) bit.add(x, 1);
			}
		}
		if(yes) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}
```