cpp
#include<bits/stdc++.h>
using namespace std;
const int N=100;
int t,n,a[N];
int k[100]={1,2,4,8,16,20};
signed main(){
scanf("%d",&t);
while(t--){
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
}
int f=1;
for(int i=0;i<5;i++){
int x=k[i],y=min(k[i+1],n);
for(int j=x+1;j<y;j++){
if(a[j]>a[j+1]){
f=0;
break;
}
}
}
if(f) puts("YES");
else puts("NO");
}
return 0;
}