#include using namespace std; const int N=1e5+10; struct node{ int l,r,x; }a[N]; bool operator<(const node&x,const node&y){ return x.l,vector>,greater>>q; scanf("%d",&m); build(1,n+1,1); int l=1; for (int i=1;i<=m;i++){ scanf("%d",&x); while (l<=n&&a[l].l<=x){ if (a[l].x+1<=n) change(1,n+1,1,a[l].x+1,1); q.push(make_pair(a[l].r,a[l].x+1)); l++; } while (!q.empty()&&q.top().first