##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
| # | Title | Points | Solved | Admin | |
|---|---|---|---|---|---|
You are given a permutation of integers from to .
For a sequence of length , its median is defined as the -th smallest element of the sequence. In particular, for even , this is the lower median.
Count the number of pairs such that and there exists an interval satisfying all of the following conditions:
For each test case, output this number.
There are no pairs of indices, so the answer is .
The good pairs are .
For , choose . The sequence is , and its median is , which is at least .
There are no good pairs.
The only pair is . The only possible interval is . The sequence is , and its median is , which is smaller than .
The good pairs are , , and .
For and , choose . The sequence is , and its median is , which is at least .
For , choose . The sequence is , and its median is , which is at least .
The good pairs are , , , and .
For and , choose . The sequence is , and its median is , which is at least .
For , choose . The sequence is , and its median is , which is at least .
For , choose . The sequence is , and its median is , which is at least .