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 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?

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 <=109)

Output Format

For each test case please output the desired answer.

Sample Input 1

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

Sample Output 1

15
3

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