#include using namespace std; int main() { int T; cin >> T; while (T--) { int N; cin >> N; vectorP(N),Q(N+1); for(int i = 0; i < N; i++) { cin >> P[i]; Q[P[i]] = i+1; } vectorres(N+2); int ans = 1,now = 1; for(int i = 1; i <= N; i++) { res[Q[i]] = 1; if(res[Q[i]-1] == 0 || res[Q[i]+1] == 0) { if(res[Q[i]-1] == 1 || res[Q[i]+1] == 1) { continue; } if(Q[i] == 1 || Q[i] == N) { now++; } else { now += 2; } ans = max(ans,now); } else { now -= 2; } } cout << ans << endl; } }