import sys read=sys.stdin.buffer.read readline=sys.stdin.buffer.readline readlines=sys.stdin.buffer.readlines import numpy as np t=int(readline()) def solve(): n=int(readline()) a=list(map(int, readline().split())) dp=np.zeros((2, n, n), np.int16) ans=1 for i in range(n): for j in range(i): if a[j]a[i] and dp[1][j][i]==0: dp[1][j][i]=2 x=dp[0][j][i] y=dp[1][j][i] if ans0: idx=[k for k in range(i+1, n) if a[i]-a[j]a[k]] dp[1][i][idx]=np.maximum(dp[1][i][idx], x+1) if y>0: idx=[k for k in range(i+1, n) if a[i]>a[k] and a[j]-a[i]>a[i]-a[k]] dp[1][i][idx]=np.maximum(dp[1][i][idx], y+1) print(ans) for _ in range(t): solve()