For a sequence of numbers a1, a2, …, an, we call a consecutive subsequence ai, …, aj weakly- perfect if the set of numbers {ai, …, aj} formed consecutive distinct integers not necessarily from i to j. Now you are given the sequence. How many weakly-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 <=107)
For each test case please output the desired answer.
Please assume test cases are almost randomly generated, and the sum of all answers does not exceed 108.
2 5 5 4 3 2 1 5 1 3 5 2 4
15 7
Migrated from old NTUJ.
tmt514
No. | Testdata Range | Score |
---|