Milly and special subarrays
Tag(s):

## Easy-Medium, Math

Problem
Editorial
Analytics

Milly is playing with an array A of size N. She is trying to find those non-empty subarrays (sequence of consecutive elements) whose maximum and minimum values are identical. Milly got confused while counting. Your task is to help her in this problem.

### Input

• First line of the input will contain T denoting the number of test-cases.
• For every test case, first line will contain N. Next line will contain N space separated integers denoting Ai.

### Output

• For every test case, print the required answer in a separate line.

### Constraints

• 1 ≤ T ≤ 10
• 1 ≤ N ≤ 105
• 1 ≤ |Ai| ≤ 109
• Here, || denotes the absolute value.

SAMPLE INPUT
1
3
1 1 3
SAMPLE OUTPUT
4
Explanation

Test case 1:
Special subarrays for the given sample case include :- [1], [1], [3], [1, 1].

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Scala 2.11.8, Swift, Visual Basic

## CODE EDITOR

Initializing Code Editor...