# Yet Another Problem About Pairs Satisfying an Inequality solution codeforces

You are given an array 1,2,a1,a2,…an. Count the number of pairs of indices 1,1≤i,j≤n such that <<<ai<i<aj<j.

## Yet Another Problem About Pairs Satisfying an Inequality solution codeforces

The first line contains an integer t (110001≤t≤1000) — the number of test cases.

The first line of each test case contains an integer n (221052≤n≤2⋅105) — the length of the array.

The second line of each test case contains n integers 1,2,,a1,a2,…,an (01090≤ai≤109) — the elements of the array.

It is guaranteed that the sum of n across all test cases does not exceed 21052⋅105.

Output

For each test case, output a single integer — the number of pairs of indices satisfying the condition in the statement.

Please note, that the answer for some test cases won’t fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).

## Yet Another Problem About Pairs Satisfying an Inequality solution codeforces

Example
input

Copy
5
8
1 1 2 3 8 2 1 4
2
1 2
10
0 2 1 6 3 4 1 2 8 3
2
1 1000000000
3
0 1000000000 2

output

Copy
3
0
10
0
1


## Yet Another Problem About Pairs Satisfying an Inequality solution codeforces

For the first test cases the pairs are (,)(i,j) = {(2,4),(2,8),(3,8)}{(2,4),(2,8),(3,8)}.

• The pair (2,4)(2,4) is true because 2=1a2=14=3a4=3 and 1<2<3<41<2<3<4.
• The pair (2,8)(2,8) is true because 2=1a2=18=4a8=4 and 1<2<4<81<2<4<8.
• The pair (3,8)(3,8) is true because 3=2a3=28=4a8=4 and 2<3<4<82<3<4<8.