For a given array A of size n, find the count of subarrays of size>=3, where the minimum of the elements at both the ends of subarray is greater than the maximum of all the numbers in between.
Formally, if the subarray starts at l and ends at r, then min(A[l], A[r]) > max(A[l+1], A[l+2],..., A[r-1]).
0<= n <=1e5 1<= A[i] <=1e9







