5 7 1 2 3 4 5
The valid pairs are (1,2), (1,3), (1,4), (1,5), (2,3), (2,4), (2,5), and (3,4), so the answer is 8.
8
4 0 -2 -1 1 3
The pairs with total at most 0 are (-2,-1), (-2,1), (-2,3), and (-1,1).
3
3 1 5 6 7
Every pair is greater than 1, so no pair is counted.
0
Given nnn integers and a limit xxx, count pairs of indices (i,j)(i, j)(i,j) with i<ji < ji<j and ai+aj≤xa_i + a_j \le xai+aj≤x.