405554: GYM101992 B The first task

Memory Limit:1024 MB Time Limit:5 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

B. The first tasktime limit per test5 secondsmemory limit per test1024 megabytesinputtask.inoutputstandard output

After being accepted as an intern in one of the biggest companies, Yasser's first task was to come up with a strategy to encrypt a huge amount of data into some permutation of integers. Here is the definition of a permutation that can be accepted by Yasser's supervisor:

  1. The maximum number in the permutation should be greater than or equal to 1.
  2. If the maximum number is $$$M$$$, it should contain all numbers from 1 to $$$M$$$.
  3. Each number should appear exactly once.
  4. The numbers can appear in any order.
  5. The permutation can't be empty.

His supervisor gave him a week to finish the task. After days of hard work he finally managed to finish the task at the night of the deadline, he was so happy and looking forward to seeing how much his supervisor will be impressed by his hard work.

Since Yasser was very tired, he fell asleep without turning off his computer, and while he was asleep dreaming about all the nice words that people are going to say about him, his little brother was messing up his result. In the morning, he discovered this disaster and found out that his brother has changed the resulting sequence and that he may have added some arbitrary integers to it or deleted some integers from it and the sequence may not be a valid permutation anymore.

Yasser now can't remember how the original permutation was like and what its length was. There is no time for him to repeat the work, but instead of punishing his brother for what he did, he decided to apply the minimum number of operations on the current sequence to make it a valid permutation again.

Each operation is either inserting or removing a number. This way he may be able to survive the meeting without being a joke and after the meeting he will have time to reconstruct the original sequence.

Input

The first line of the input contains the number of test cases $$$T$$$. Each test case starts with a line that contains a single integer $$$N$$$ the length of the current sequence, where $$$1 \leq N \leq 10^5$$$.

The following line contains $$$N$$$ space-separated integers representing the sequence. Each integer is between 1 and $$$10^9$$$ inclusive.

Output

For each test case output a single line contains the minimum number of operations.

ExampleInput
1
4
1 1 3 4
Output
2
Note

Please note that Yasser can make a permutation of any length even of length 1. The only thing that matters is to reach a valid permutation accepted by his supervisor by using the minimum number of operations.

加入题单

上一题 下一题 算法标签: