func_code_string: #include<bits/stdc++.h>   #include<algorithm>   #include<iostream>   #include<cstdio>   #include<cmath>   #include<cstring>   #include<stack>   #include<queue>   using namespace std;   typedef long long ll;   const ll INF=0x7f7f7f7f;   const int maxn=2e5+7;   const ll mod=1e9+7;   ll read(){       ll f=0,x=0;char ch=getchar();       while(!isdigit(ch)){if(ch== - ) f=1;ch=getchar();}       while(isdigit(ch)){x=x*10+ch- 0 ;ch=getchar();}       return !f?x:-x;   }   int tt,n,s[maxn];   bool check(int x,int y){       if(x==3){           if(s[y]>=s[y+1]&&s[y+1]>=s[y+2]) return false;           if(s[y]<=s[y+1]&&s[y+1]<=s[y+2]) return false;           return true;       }       else{           for(int i=0;i<4;i++){               for(int j=i+1;j<4;j++){                   for(int k=j+1;k<4;k++){                       if(s[y+i]>=s[y+j]&&s[y+j]>=s[y+k]) return false;                       if(s[y+i]<=s[y+j]&&s[y+j]<=s[y+k]) return false;                   }               }           }           return true;       }   }   int main(){       scanf( %d ,&tt);       while(tt--){           ll ans=0;           scanf( %d ,&n);           for(int i=1;i<=n;i++){               scanf( %d ,&s[i]);           }           ans+=2*n-1;           for(int i=3;i<=4;i++){               for(int j=1;j<=n-i+1;j++){                   if(check(i,j)) ans++;               }           }           printf( %lld n ,ans);       }       return 0;   }