#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int t, N, i, j, cheater, id;
  scanf("%d", &t);
  while (t--) {
    int arr[1002] = {0};
    cheater = 0;
    scanf("%d", &N);
    for (i = 0; i < N; i++) {
      scanf("%d", &id);
      if (!arr[id])
        arr[id] = 1;
      else if (arr[id] == 1) {
        arr[id]++;
        cheater++;
      } else
        arr[id]++;
    }
    printf("%d\n", cheater);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfd0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     124f <main+0x11f>
lea    -0xfd0(%rbp),%rdi
xor    %esi,%esi
mov    $0xfa8,%edx
call   1040 <memset@plt>
movl   $0x0,-0x18(%rbp)
lea    0xe79(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    123b <main+0x10b>
lea    0xe56(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1050 <scanf@plt>
movslq -0x1c(%rbp),%rax
cmpl   $0x0,-0xfd0(%rbp,%rax,4)
jne    11d9 <main+0xa9>
movslq -0x1c(%rbp),%rax
movl   $0x1,-0xfd0(%rbp,%rax,4)
jmp    1228 <main+0xf8>
movslq -0x1c(%rbp),%rax
cmpl   $0x1,-0xfd0(%rbp,%rax,4)
01
jne    120e <main+0xde>
movslq -0x1c(%rbp),%rax
mov    -0xfd0(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0xfd0(%rbp,%rax,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1223 <main+0xf3>
movslq -0x1c(%rbp),%rax
mov    -0xfd0(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0xfd0(%rbp,%rax,4)
jmp    1228 <main+0xf8>
jmp    122d <main+0xfd>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1197 <main+0x67>
mov    -0x18(%rbp),%esi
lea    0xdbe(%rip),%rdi
call   1030 <printf@plt>
jmp    1152 <main+0x22>
xor    %eax,%eax
add    $0xfd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xfb8,%rsp
lea    0xeb8(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
subl   $0x1,0x8(%rsp)
jae    116d <main+0x3d>
xor    %eax,%eax
add    $0xfb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe8c(%rip),%rbx
lea    0x4(%rsp),%r15
lea    0xc(%rsp),%r12
lea    0xe7e(%rip),%r13
jmp    11a1 <main+0x71>
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
subl   $0x1,0x8(%rsp)
jb     1159 <main+0x29>
xor    %ebp,%ebp
mov    $0xfa8,%edx
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1040 <memset@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    1190 <main+0x60>
xor    %ebp,%ebp
xor    %r14d,%r14d
jmp    11e2 <main+0xb2>
nopl   (%rax)
add    $0x1,%ecx
mov    %ecx,0x10(%rsp,%rax,4)
add    $0x1,%r14d
cmp    0x4(%rsp),%r14d
jge    1190 <main+0x60>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
movslq 0xc(%rsp),%rax
mov    0x10(%rsp,%rax,4),%ecx
cmp    $0x1,%ecx
je     1210 <main+0xe0>
test   %ecx,%ecx
jne    11d0 <main+0xa0>
movl   $0x1,0x10(%rsp,%rax,4)
jmp    11d7 <main+0xa7>
nopl   0x0(%rax)
movl   $0x2,0x10(%rsp,%rax,4)
add    $0x1,%ebp
jmp    11d7 <main+0xa7>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [1002 x i32]
store i32 0, i32* %1
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %10
10: ; preds = %57, %0
%11 = load i32, i32* %2
%12 = add nsw i32 %11, -1
store i32 %12, i32* %2
%13 = icmp ne i32 %11, 0
br i1 %13, label %14, label %60
14: ; preds = %10
%15 = bitcast [1002 x i32]* %8 to i8*
store i32 0, i32* %6
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
store i32 0, i32* %4
br label %17
17: ; preds = %54, %14
%18 = load i32, i32* %4
%19 = load i32, i32* %3
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %57
21: ; preds = %17
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [1002 x i32], [1002 x i32]* %8, i64 0, i64 %24
%26 = load i32, i32* %25
%27 = icmp ne i32 %26, 0
br i1 %27, label %32, label %28
28: ; preds = %21
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [1002 x i32], [1002 x i32]* %8, i64 0, i64 %30
store i32 1, i32* %31
br label %53
32: ; preds = %21
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [1002 x i32], [1002 x i32]* %8, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = icmp eq i32 %36, 1
br i1 %37, label %38, label %46
38: ; preds = %32
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [1002 x i32], [1002 x i32]* %8, i64 0, i64 %40
%42 = load i32, i32* %41
%43 = add nsw i32 %42, 1
store i32 %43, i32* %41
%44 = load i32, i32* %6
%45 = add nsw i32 %44, 1
store i32 %45, i32* %6
br label %52
46: ; preds = %32
%47 = load i32, i32* %7
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [1002 x i32], [1002 x i32]* %8, i64 0, i64 %48
%50 = load i32, i32* %49
%51 = add nsw i32 %50, 1
store i32 %51, i32* %49
br label %52
52: ; preds = %46, %38
br label %53
53: ; preds = %52, %28
br label %54
54: ; preds = %53
%55 = load i32, i32* %4
%56 = add nsw i32 %55, 1
store i32 %56, i32* %4
br label %17
57: ; preds = %17
%58 = load i32, i32* %6
%59 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %58)
br label %10
60: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [1002 x i32]
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = add nsw i32 %9, -1
store i32 %10, i32* %1
%11 = icmp eq i32 %9, 0
br i1 %11, label %42, label %12
12: ; preds = %0
%13 = bitcast [1002 x i32]* %4 to i8*
br label %14
14: ; preds = %12, %36
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%16 = load i32, i32* %2
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %36
18: ; preds = %14, %31
%19 = phi i32 [ %32, %31 ], [ 0, %14 ]
%20 = phi i32 [ %33, %31 ], [ 0, %14 ]
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%22 = load i32, i32* %3
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [1002 x i32], [1002 x i32]* %4, i64 0, i64 %23
%25 = load i32, i32* %24
switch i32 %25, label %29 [
i32 0, label %26
i32 1, label %27
]
26: ; preds = %18
store i32 1, i32* %24
br label %31
27: ; preds = %18
store i32 2, i32* %24
%28 = add nsw i32 %19, 1
br label %31
29: ; preds = %18
%30 = add nsw i32 %25, 1
store i32 %30, i32* %24
br label %31
31: ; preds = %26, %29, %27
%32 = phi i32 [ %28, %27 ], [ %19, %29 ], [ %19, %26 ]
%33 = add nuw nsw i32 %20, 1
%34 = load i32, i32* %2
%35 = icmp slt i32 %33, %34
br i1 %35, label %18, label %36
36: ; preds = %31, %14
%37 = phi i32 [ 0, %14 ], [ %32, %31 ]
%38 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %37)
%39 = load i32, i32* %1
%40 = add nsw i32 %39, -1
store i32 %40, i32* %1
%41 = icmp eq i32 %39, 0
br i1 %41, label %42, label %14
42: ; preds = %36, %0
ret i32 0
}