#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second

#define INF 2147483600

typedef pair<int, int> P;
set<P > s;
// ?????????[begin, end]?????\???

bool ins(int d){
  if(s.size()==0){
    s.insert(mp(d,d));
    return true;
  }
  if(s.begin()->fi==0){
    return false;
  }

  auto p = s.upper_bound(mp(d,INF));
  if(p == s.begin()){
    if(p->fi == d+1){
      s.insert(mp(d, p->se));
      s.erase(p);
      return true;
    } else {
      s.insert(mp(d,d));
      return true;
    }
  }

  p--;
  if(p->fi <= d && p->se >= d ){
    P tmp = *p;
    if(tmp.fi==1 && !(s.size()==1 && tmp.se==d) ) return false;
    if(tmp.se > d) s.insert(mp(d+1, tmp.se));
    s.erase(p);
    return ins(tmp.fi-1);
  }

  int newl=d, newr=d;
  P pl = *p;
  auto pp = p;
  pp++;
  P pr = *pp;

  if(pl.se+1==d){
    newl = pl.fi;
    s.erase(p);
  }
  if(pp!=s.end() && pr.fi-1==d){
    newr = pr.se;
    s.erase(pp);
  }

  s.insert(mp(newl, newr));
  return true;
}

int main(){
  int n;
  cin>>n;

  rep(i,n){
    int d;
    scanf("%d", &d);
    if(ins(d)) printf("Yes\n");
    else printf("No\n");
  }

  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 <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second

#define INF 2147483600

typedef pair<int, int> P;
set<P > s;
// ?????????[begin, end]?????\???

bool ins(int d){
  if(s.size()==0){
    s.insert(mp(d,d));
    return true;
  }
  if(s.begin()->fi==0){
    return false;
  }

  auto p = s.upper_bound(mp(d,INF));
  if(p == s.begin()){
    if(p->fi == d+1){
      s.insert(mp(d, p->se));
      s.erase(p);
      return true;
    } else {
      s.insert(mp(d,d));
      return true;
    }
  }

  p--;
  if(p->fi <= d && p->se >= d ){
    P tmp = *p;
    if(tmp.fi==1 && !(s.size()==1 && tmp.se==d) ) return false;
    if(tmp.se > d) s.insert(mp(d+1, tmp.se));
    s.erase(p);
    return ins(tmp.fi-1);
  }

  int newl=d, newr=d;
  P pl = *p;
  auto pp = p;
  pp++;
  P pr = *pp;

  if(pl.se+1==d){
    newl = pl.fi;
    s.erase(p);
  }
  if(pp!=s.end() && pr.fi-1==d){
    newr = pr.se;
    s.erase(pp);
  }

  s.insert(mp(newl, newr));
  return true;
}

int main(){
  int n;
  cin>>n;

  rep(i,n){
    int d;
    scanf("%d", &d);
    if(ins(d)) printf("Yes\n");
    else printf("No\n");
  }

  return 0;
}
```