Hide

Problem G
Sports Rank

Accepted submissions to this problem will be granted a score of 100

Sports leagues rank their participants (teams or players) using a variety of point systems, but at the end of the day, all the fans really want to know is the rank of their team. This is where things get complicated, because there are several fairly common ranking systems in use.

In competition ranking, a.k.a. “1224 ranking”, each participant’s ranking is 1 plus the number of participants ranked above them.

In dense ranking, a.k.a. “1223 ranking”, each participant’s ranking is 1 plus the number of distinct ranks above them.

Clearly some fans may prefer dense ranking over competition ranking for “their” team, since it makes their favorite sound better.

Input

The first input line will contain the number of data sets ($1 \le d \le 1000$).

The next $d$ lines each contain integers separated by single spaces. The first integer ($1 \le n \le 100$) indicates the number of scores ($0 \le s \le 2000$) to follow.

Output

Each data set should produce one line of output containing the number of participants who benefit from dense ranking.

Sample Input 1 Sample Output 1
3
3 80 70 70
10 50 60 70 10 20 30 40 30 80 90
5 50 50 50 50 50
0
2
0

Please log in to submit a solution to this problem

Log in