#include <bits/stdc++.h>
using namespace std;
const int N = 6e6+3;
int a[N], s[N];
int n, x, qw = 555555;

struct Fenwick {
  void add(int p, int nu) {
    while (p <= qw) {
      s[p] += nu;
      p += p&-p;
    }
  }
  int ask(int p, int ans = 0) {
    for (; p > 0; p -= p & -p)
      ans += s[p];
    return ans;
  }
} f;

int main() {
  scanf("%d", &n);
  while (n--) {
    scanf("%d", &x);
    x = min(x, qw);
    if (a[0] > 0 || (f.ask(x) == x && f.ask(qw) > f.ask(x))) { puts("No"); continue; }
    puts("Yes");
    for (; a[x] == 1; --x)
      a[x] = 0, f.add(x, -1);
    a[x] = 1; if (x > 0) f.add(x, 1);
  }
  return 0;
}

### Prompt

Create a solution in CPP for 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;
const int N = 6e6+3;
int a[N], s[N];
int n, x, qw = 555555;

struct Fenwick {
  void add(int p, int nu) {
    while (p <= qw) {
      s[p] += nu;
      p += p&-p;
    }
  }
  int ask(int p, int ans = 0) {
    for (; p > 0; p -= p & -p)
      ans += s[p];
    return ans;
  }
} f;

int main() {
  scanf("%d", &n);
  while (n--) {
    scanf("%d", &x);
    x = min(x, qw);
    if (a[0] > 0 || (f.ask(x) == x && f.ask(qw) > f.ask(x))) { puts("No"); continue; }
    puts("Yes");
    for (; a[x] == 1; --x)
      a[x] = 0, f.add(x, -1);
    a[x] = 1; if (x > 0) f.add(x, 1);
  }
  return 0;
}

```