import java.util.Arrays; import java.util.Scanner; public class Main_yukicoder209 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for (int tcase = 0; tcase < t; tcase++) { n = sc.nextInt(); a = new int[n]; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); } ldp = new int[n][n]; rdp = new int[n][n]; for (int i = 0; i < n; i++) { Arrays.fill(ldp[i], -1); Arrays.fill(rdp[i], -1); } int max = 0; for (int j = 0; j < n; j++) { int lmax = 0; for (int i = 0; i < j; i++) { lmax = Math.max(lmax, L(i, j)); } int rmax = 0; for (int k = j + 1; k < n; k++) { rmax = Math.max(rmax, R(j, k)); } max = Math.max(max, lmax + 1 + rmax); } System.out.println(max); } sc.close(); } private static int n; private static int[] a; private static int[][] ldp; private static int[][] rdp; private static int L(int i, int j) { if (ldp[i][j] != -1) { return ldp[i][j]; } if (i == j || a[j] - a[i] <= 0) { return ldp[i][j] = 0; } int ret = 1; for (int k = 0; k < i; k++) { if (a[j] - a[i] > a[i] - a[k]) { ret = Math.max(ret, L(k, i) + 1); } } return ldp[i][j] = ret; } private static int R(int i, int j) { if (rdp[i][j] != -1) { return rdp[i][j]; } if (i == j || a[i] - a[j] <= 0) { return rdp[i][j] = 0; } int ret = 1; for (int k = j + 1; k < n; k++) { if (a[i] - a[j] > a[j] - a[k]) { ret = Math.max(ret, R(j, k) + 1); } } return rdp[i][j] = ret; } }