#include #include #include #include #include #include #define M 100007 #define LL long long using namespace std; int rd(){ int res=0,k=1;char c; while(c=getchar(),!isdigit(c)&&c!='-'); if(c=='-'){k=-1;c=getchar();} do{ res=(res<<3)+(res<<1)+(c^48); }while(c=getchar(),isdigit(c)); return res*k; } int T,n,k,A[M],B[M],res[M]; bool check(int x){ for(int i=1;i<=n/x;i++){ int st=(i-1)*x+1; for(int j=1;j<=x;j++)res[A[j]]++; for(int j=st;j<=st+x-1;j++){ res[A[j]]--; } for(int j=1;j<=k;j++)if(res[j])return false; } return true; } int main(){ T=rd(); while(T--){ n=rd(); for(int i=1;i<=n;i++){A[i]=rd();B[i-1]=A[i];} sort(B,B+n); k=unique(B,B+n)-B; for(int i=1;i<=n;i++)A[i]=lower_bound(B,B+k,A[i])-B+1; for(int i=1;i