#arc162a. [arc162_a]Ekiden Race

[arc162_a]Ekiden Race

Problem Statement

There are NN people, numbered from 11 to NN, who participated in a round-trip race between two points. The following information is recorded about this race.

  • The outward times of any two people were different, and person ii (1leqileqN)(1 \\leq i \\leq N) had the ii-th fastest outward time.
  • The round-trip times (the sum of the outward and return times) of any two people were different, and person ii (1leqileqN)(1 \\leq i \\leq N) had the PiP_i-th fastest round-trip time.
  • The person (or persons) with the fastest return time was awarded the fastest return award.

Here, P1,P2,dots,PNP_1, P_2, \\dots, P_N is a permutation of 1,2,dots,N1, 2, \\dots, N.

How many people could have received the fastest return award?

There are TT test cases. Answer each of them.

Constraints

  • 1leqTleq5001 \\leq T \\leq 500
  • 2leqNleq1032 \\leq N \\leq 10^3
  • P1,P2,dots,PNP_1, P_2, \\dots, P_N is a permutation of 1,2,dots,N1, 2, \\dots, N.
  • All input values are integers.
  • The sum of NN over all test cases in a single input is at most 10310^3.

Input

The input is given from Standard Input in the following format:

TT mathrmcase1\\mathrm{case}_1 vdots\\vdots mathrmcaseT\\mathrm{case}_T

Each test case, mathrmcasei(1leqileqT)\\mathrm{case}_i\\ (1 \\leq i \\leq T), is given in the following format:

NN P1P_1 P2P_2 cdots\\cdots PNP_N

Output

Print TT lines. The ii-th line (1leqileqT)(1 \\leq i \\leq T) should contain the answer for the ii-th test case.


Sample Input 1

3
2
2 1
4
1 2 3 4
20
13 2 7 1 5 9 3 4 12 10 15 6 8 14 20 16 19 18 11 17

Sample Output 1

1
4
7
  • In the first test case, two people participated in the race, and person 22 overtook person 11 on the return leg. In this case, the fastest return award is awarded to person 22.
  • In the second test case, the rankings did not change on the return leg, so any person could have received the fastest return award.