2017 JUST Programming Contest 4.0 |
---|
Finished |
Alaa sometimes feels bored at work, so at such times she starts playing with a beautiful array a consisting of n integers a1, a2, ..., an.
Alaa starts counting the number of magical indices in the array a. An index x is said to be magical if it satisfying the following rules:
Can you help Alaa by counting the number of magical indices in the array a.
The first line contains an integer T, where T is the number of test cases.
The first line of each test case contains an integer n (1 ≤ n ≤ 106), where n is the size of the array a.
The second line of each test case contains n integers a1, a2, ..., an (1 ≤ ai ≤ 106), giving the array a.
For each test case, print a single line containing the number of magical indices in the array a.
2
8
2 1 3 4 6 5 7 9
6
4 2 7 9 8 10
3
1
As input/output can reach huge size it is recommended to use fast input/output methods: for example, prefer to use scanf/printf instead of cin/cout in C++, prefer to use BufferedReader/PrintWriter instead of Scanner/System.out in Java.
Name |
---|