import io, os input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline T=int(input()) for tests in range(T): N=int(input()) A=list(map(int,input().split())) if N==1: print(1) continue DP=[[2]*N for i in range(N)] for i in range(N): a=A[i] for j in range(i): b=A[j] for k in range(j,i): c=A[k] if ba: DP[k][i]=max(DP[k][i],DP[j][k]+1) if b>c and c>a and abs(b-c)>abs(a-c): DP[k][i]=max(DP[k][i],DP[j][k]+1) ANS=1 for i in range(N): for j in range(N): ANS=max(ANS,DP[i][j]) print(ANS)