from functools import cache def solve(): N = int(input()) A = list(map(int, input().split())) def f(p, d, delta): res = 0 i = p + delta while 0 <= i < N: d2 = abs(A[p] - A[i]) if d2 < d: res = max(res, f(i, d2, delta) + 1) i += delta return res res = 0 for i in range(N): res = max(res, f(i, INF, -1) + f(i, INF, 1)) return res INF = 1 << 60 T = int(input()) for _ in range(T): ans = solve() print(ans)