#include using namespace std; using Int = long long; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a vector make_v(size_t a){return vector(a);} template auto make_v(size_t a,Ts... ts){ return vector(ts...))>(a,make_v(ts...)); } template typename enable_if::value!=0>::type fill_v(U &u,const V... v){u=U(v...);} template typename enable_if::value==0>::type fill_v(U &u,const V... v){ for(auto &e:u) fill_v(e,v...); } //INSERT ABOVE HERE int solve(){ int n; cin>>n; vector a(n); for(int i=0;i>a[i]; auto dp=make_v(2,n,n); fill_v(dp,-n*2); for(int i=0;i=abs(a[j]-a[k])) continue; if(cf==0&&abs(a[i]-a[j])<=abs(a[j]-a[k])) continue; } chmax(dp[nf][j][k],dp[cf][i][j]+1); } } } int ans=1; for(int k=0;k<2;k++) for(int i=0;i>T; while(T--) solve(); return 0; }