For a sequence of numbers a1, a2, …, an, we call a consecutive subsequence ai, …, aj perfect if the set of numbers {ai, …, aj} formed consecutive integers exactly from i to j. Now you are given the sequence. How many perfect consecutive subsequences are there?
First line contains an integer T (T<=100) indicating the number of test cases. For each test case, first line contains an integer n (1<=n<=100000). Second line contains n integers a1, a2, …, an. (0<= ai <=109)
For each test case please output the desired answer.
2 5 1 2 3 4 5 5 5 4 3 2 1
15 3
Migrated from old NTUJ.
tmt514
No. | Testdata Range | Score |
---|