func_code_string: #include <bits/stdc++.h>   typedef long long ll;   #define endl   n    #define pq priority_queue <pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>   #define graph1 vector<vector<pair<ll,ll>>>   #define graph vector<vector<ll>>   #define pq1 priority_queue<pair<ll, pair<ll, ll>>, vector<pair<ll, pair<ll,ll>>>, greater<pair<ll, pair<ll, ll>>>>   #define loop(i,a,b) for (ll i = a; i < b; i++)   using namespace std;   vector <ll>  arr;   bool check3(ll i)   {       if(max(arr[i],arr[i+2]) >=  arr[i+1] && min(arr[i],arr[i+2]) <=  arr[i+1]  )       {           return true;       }       return false;   }   bool check4(ll i)   {       if(check3(i) ||check3(i + 1))       {           return true;       }       if(max(arr[i],arr[i+3]) >=  arr[i + 1] && min(arr[i],arr[i+3]) <=  arr[i+1]  )       {           return true;       }       if(max(arr[i],arr[i+3]) >=  arr[i + 2] && min(arr[i],arr[i+3]) <=  arr[i+2]  )       {           return true;       }       return false;   }   int main()   {       ios::sync_with_stdio(0); cin.tie(0);       ll t;       cin >> t;       while(t--)       {           ll n;           cin >> n;           arr.resize(n);           loop(i,0,n)               cin >> arr[i];              ll ans = n * 2 - 1;              loop(i,0,n-2)           {               if(!check3(i))               ans++;           }           loop(i,0,n-3)           {               if(!check4(i))               ans++;           }           cout << ans << endl;       }   }