{"trustable":true,"sections":[{"title":"","value":{"format":"MD","content":"### Read problems statements [Mandarin](https://www.codechef.com/download/translated/LTIME70/mandarin/PERMPART.pdf) , [Bengali](https://www.codechef.com/download/translated/LTIME70/bengali/PERMPART.pdf) , [Hindi](https://www.codechef.com/download/translated/LTIME70/hindi/PERMPART.pdf) , [Russian](https://www.codechef.com/download/translated/LTIME70/russian/PERMPART.pdf) and [Vietnamese](https://www.codechef.com/download/translated/LTIME70/vietnamese/PERMPART.pdf) as well.\n\nYou are given an array of integers $[A_1, A_2, \\ldots, A_N]$. Let\u0027s call adding an element to this array at any position (including the beginning and the end) or removing an arbitrary element from it a *modification*. It is not allowed to remove an element from the array if it is empty.\n\nFind the minimum number of modifications which must be performed so that the resulting array can be partitioned into permutations. Formally, it must be possible to partition elements of the resulting array into zero or more groups (multisets; not necessarily identical) in such a way that each element belongs to exactly one group and for each group, if it contains $L$ elements, then it must contain only integers $1$ through $L$, each of them exactly once.\n\n### Input\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of each test case contains a single integer $N$.\n- The second line contains $N$ space-separated integers $A_1, A_2, \\ldots, A_N$.\n\n### Output\nFor each test case, print a single line containing one integer ― the minimum required number of modifications.\n\n### Constraints \n- $1 \\le T \\le 1,000$\n- $1 \\le N \\le 10^6$\n- $1 \\le A_i \\le 10^9$ for each valid $i$\n- the sum of $N$ over all test cases does not exceed $10^6$\n\n### Subtasks\n**Subtask #1 (50 points):**\n- $1 \\le N \\le 1,000$\n- the sum of $N$ over all test cases does not exceed $10,000$\n\n**Subtask #2 (50 points):** original constraints"}},{"title":"Sample 1","value":{"format":"MD","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e2\n5\n1 4 1 2 2\n4\n2 3 2 3\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\n2\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}