#include void chmax(int* a, int b) { if (*a < b) *a = b; } int solve(int N, int P[]) { int i; static int P_inv[500001]; for (i = 1; i <= N; i++) P_inv[P[i]] = i; int j, ans = 1, tmp = 1; for (i = 1; i <= N; i++) { j = P_inv[i]; if (j == 1) { if (P[j] > P[j+1]) tmp--; else tmp++; } else if (j == N) { if (P[j-1] < P[j]) tmp--; else tmp++; } else { if (P[j-1] < P[j] && P[j] > P[j+1]) tmp -= 2; else if (P[j-1] > P[j] && P[j] < P[j+1]) tmp += 2; } chmax(&ans, tmp); } return ans; } int main() { int i, t, T, N, P[500001]; scanf("%d", &T); for (t = 1; t <= T; t++) { scanf("%d", &N); for (i = 1; i <= N; i++) scanf("%d", &(P[i])); printf("%d\n", solve(N, P)); } fflush(stdout); return 0; }