#include #include #include using namespace std; #define RREP(i,s,e) for (i = s; i >= e; i--) #define rrep(i,n) RREP(i,(int)(n)-1,0) #define REP(i,s,e) for (i = s; i <= e; i++) #define rep(i,n) REP(i,0,(int)(n)-1) #define INF 100000000 typedef long long ll; int n; int a[100]; int cnt[100]; int rcnt[100]; int dp[100][100]; int dfs(int now, int prev) { if (dp[prev][now]) return dp[prev][now]; int i, ret; ret = 1; REP (i,now+1,n-1) { if (a[i] < a[now] && (now == prev || a[now] - a[i] < a[prev] - a[now])) ret = max(ret,1+dfs(i,now)); } return dp[prev][now] = ret; } int rdfs(int now, int prev) { if (dp[prev][now]) return dp[prev][now]; int i, ret; ret = 1; REP (i,0,now-1) { if (a[i] < a[now] && (now == prev || a[now] - a[i] < a[prev] - a[now])) ret = max(ret,1+rdfs(i,now)); } return dp[prev][now] = ret; } int main() { int t; cin >> t; while (t--) { int i, ans; cin >> n; rep (i,n) cin >> a[i]; rep (i,n) fill(dp[i],dp[i]+n,0); rep (i,n) cnt[i] = dfs(i,i); rep (i,n) dp[i][i] = 0; rep (i,n) rcnt[i] = rdfs(i,i); ans = 0; rep (i,n) ans = max(ans,cnt[i]+rcnt[i]-1); cout << ans << endl; } return 0; }