TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

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?

Input Format

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)

Output Format

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.

Sample Input 1

2
5
5 4 3 2 1
5
1 3 5 2 4

Sample Output 1

15
7

Hints

Problem Source

Migrated from old NTUJ.

tmt514

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 5000 65536 200