#include #include #include #include #include #include #include using namespace std; const int N=50005; int n,a[N],p[N],tr[N],fa[N],x,T,l,r,mid; int lowbit(int x) { return x&-x; } void add(int x) { for (;x<=n;x+=lowbit(x)) tr[x]++; } int get(int x) { int sum=0; for (;x;x-=lowbit(x)) sum+=tr[x]; return sum; } int GET(int x) { if (fa[x]==x) return x; else return fa[x]=GET(fa[x]); } bool check() { for (int i=1;i<=n;i++) { int sum=0; for (int j=1;j>T; while (T--) { memset(tr,0,sizeof(tr)); cin>>n; for (int i=1;i<=n;i++) scanf("%d",&a[i]),fa[i]=i; for (int i=n;i;i--) { l=x=i-(a[i]-a[i-1]); r=n; while (l