#K7896. Unique Ranking Reformation
Unique Ranking Reformation
Unique Ranking Reformation
A gaming company is updating its competitive ranking system. In the new system, every player must have a unique rank and the rank must lie within the range \(1 \leq rank \leq n\), where \(n\) is the total number of players.
You are given the current assigned ranks for each player. Your task is to determine the minimum number of changes required to adjust the ranks so that all players have unique and valid ranks. If it is impossible to achieve a valid ranking, output -1.
Note: A change consists of modifying a player's rank to any number between 1 and n that is not currently used. The input is provided through standard input and output should be printed to standard output.
inputFormat
The first line of input contains an integer \(T\), the number of test cases.
Each test case consists of two lines. The first line contains an integer \(n\) (the total number of players). The second line contains \(n\) space-separated integers representing the ranks assigned to each player.
Input is read from standard input (stdin).
outputFormat
For each test case, print a single integer representing the minimum number of changes required to make all ranks unique and valid. If it is not possible to obtain a valid ranking, print -1.
Output is printed to standard output (stdout), with each answer on a separate line.
## sample2
5
4 4 4 4 4
3
3 2 1
4
0
</p>