Problem: We define the (Maximum Appearing Duplicate) in an array as the largest number that appears at least twice in the array. Specifically, if there is no number that appears at least twice, the value is .
For example, , , .
You are given an array of size . Initially, a variable is set to .
The following process will be executed in a sequential loop until all numbers in become :
- Set ;
- Let be an array of size . Set for all , and then set for all .
Find the value of after the process.
Input Format: The first line contains an integer () — the number of test cases.
For each test case:
- The first line contains an integer () — the size of the array ;
- The second line contains integers () — the elements of the array.
It is guaranteed that the sum of over all test cases will not exceed .
Output Format: For each test case, output the value of in a new line.
Note: In the first test case, initially.
In the first loop:
- Set ;
- Set , and then set .
After the first loop, and the process ends. The value of after the process is .
In the second test case, initially.
After the first loop, and .
After the second loop, and .
After the third loop, and . Then the process ends.
The value of after the process is .