import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop; void solve() { auto N = readln.chomp.to!int; auto H = readln.split.map!(to!int).array; auto dp_left = new Tuple!(int, int)[](N); foreach (i; 0..N) { dp_left[i] = tuple(1, 0); foreach (j; 0..i) { if (H[i] - H[j] <= dp_left[j][1]) continue; if (dp_left[i][0] < dp_left[j][0] + 1) dp_left[i] = tuple(dp_left[j][0] + 1, H[i] - H[j]); else if (dp_left[i][0] == dp_left[j][0] + 1) dp_left[i] = tuple(dp_left[j][0] + 1, min(H[i] - H[j], dp_left[i][1])); } } auto dp_right = new Tuple!(int, int)[](N); foreach (i; iota(N-1, -1, -1)) { dp_right[i] = tuple(1, 0); for (int j = N - 1; j > i; j--) { if (H[i] - H[j] <= dp_right[j][1]) continue; if (dp_right[i][0] < dp_right[j][0] + 1) dp_right[i] = tuple(dp_right[j][0] + 1, H[i] - H[j]); else if (dp_right[i][0] == dp_right[j][0] + 1) dp_right[i] = tuple(dp_right[j][0] + 1, min(H[i] - H[j], dp_right[i][1])); } } int ans = 0; foreach (i; 0..N) ans = max(ans, dp_left[i][0] + dp_right[i][0] - 1); ans.writeln; } void main() { auto T = readln.chomp.to!int; while (T--) solve; }