Given a set of integers (it can contain equal elements).

You have to split it into two subsets $A$ and $B$ (both of them can contain equal elements or be empty). You have to maximize the value of $mex(A)+mex(B)$.

Here $mex$ of a set denotes the smallest non-negative integer that doesn't exist in the set. For example:   $mex(\{1,4,0,2,2,1\})=3$  $mex(\{3,3,2,1,3,0,0\})=4$  $mex(\varnothing)=0$ ($mex$ for empty set) 

The set is splitted into two subsets $A$ and $B$ if for any integer number $x$ the number of occurrences of $x$ into this set is equal to the sum of the number of occurrences of $x$ into $A$ and the number of occurrences of $x$ into $B$.


-----Input-----

The input consists of multiple test cases. The first line contains an integer $t$ ($1\leq t\leq 100$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains an integer $n$ ($1\leq n\leq 100$) — the size of the set.

The second line of each testcase contains $n$ integers $a_1,a_2,\dots a_n$ ($0\leq a_i\leq 100$) — the numbers in the set.


-----Output-----

For each test case, print the maximum value of $mex(A)+mex(B)$.


-----Example-----
Input
4
6
0 2 1 5 0 1
3
0 1 2
4
0 2 0 1
6
1 2 3 4 5 6

Output
5
3
4
0



-----Note-----

In the first test case, $A=\left\{0,1,2\right\},B=\left\{0,1,5\right\}$ is a possible choice.

In the second test case, $A=\left\{0,1,2\right\},B=\varnothing$ is a possible choice.

In the third test case, $A=\left\{0,1,2\right\},B=\left\{0\right\}$ is a possible choice.

In the fourth test case, $A=\left\{1,3,5\right\},B=\left\{2,4,6\right\}$ is a possible choice.

Source: codeforces | Difficulty: EASY
Tags: Mathematics

Implementation

Greedy algorithms


Solutions:
for _ in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	(A, B) = (0, 0)
	for i in a:
		if A == i:
			A += 1
		elif B == i:
			B += 1
	print(A + B)


def Ans():
	N = int(input())
	for i in range(N):
		A = int(input())
		B = sorted(list(map(int, input().split())))
		a = 0
		ans = 0
		C = B
		for i in range(len(B) + 1):
			if i not in B:
				ans += i
				break
			else:
				C.remove(i)
		D = C
		for i in range(len(C) + 1):
			if i not in C:
				ans += i
				break
			else:
				D.remove(i)
		print(ans)
Ans()


def mex(A, B, m):
	find = [i for i in range(0, m + 2)]
	for item in find:
		if item not in A:
			mex_A = item
			break
	for item in find:
		if item not in B:
			mex_B = item
			break
	return mex_A + mex_B

def solve(a):
	a.sort()
	m = max(a)
	A = []
	B = []
	for item in a:
		if item not in A:
			A.append(item)
		else:
			B.append(item)
	return mex(list(set(A)), list(set(B)), m)
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	print(solve(a))


from sys import stdin, stdout
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	s1 = set()
	s2 = set()
	for i in range(n):
		if a[i] in s1:
			s2.add(a[i])
		else:
			s1.add(a[i])
	ans = 0
	for i in range(101):
		if i not in s1:
			ans += i
			break
	for i in range(101):
		if i not in s2:
			ans += i
			break
	print(ans)


def check(arr, l):
	for i in range(l):
		if arr[i] != i:
			return i
	else:
		return i + 1

def solve(l):
	d = {0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0, 17: 0, 18: 0, 19: 0, 20: 0, 21: 0, 22: 0, 23: 0, 24: 0, 25: 0, 26: 0, 27: 0, 28: 0, 29: 0, 30: 0, 31: 0, 32: 0, 33: 0, 34: 0, 35: 0, 36: 0, 37: 0, 38: 0, 39: 0, 40: 0, 41: 0, 42: 0, 43: 0, 44: 0, 45: 0, 46: 0, 47: 0, 48: 0, 49: 0, 50: 0, 51: 0, 52: 0, 53: 0, 54: 0, 55: 0, 56: 0, 57: 0, 58: 0, 59: 0, 60: 0, 61: 0, 62: 0, 63: 0, 64: 0, 65: 0, 66: 0, 67: 0, 68: 0, 69: 0, 70: 0, 71: 0, 72: 0, 73: 0, 74: 0, 75: 0, 76: 0, 77: 0, 78: 0, 79: 0, 80: 0, 81: 0, 82: 0, 83: 0, 84: 0, 85: 0, 86: 0, 87: 0, 88: 0, 89: 0, 90: 0, 91: 0, 92: 0, 93: 0, 94: 0, 95: 0, 96: 0, 97: 0, 98: 0, 99: 0, 100: 0}
	m = 0
	for i in l:
		d[i] += 1
		if i > m:
			m = i
	l = []
	r = []
	ll = 0
	lr = 0
	for i in range(m + 1):
		if d[i] >= 2:
			r.append(i)
			lr += 1
			ll += 1
			l.append(i)
		elif d[i] == 1:
			ll += 1
			l.append(i)
	if lr > 0:
		return check(l, ll) + check(r, lr)
	else:
		return check(l, ll)
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	print(solve(l))


R = lambda : map(int, input().split())
(t,) = R()
for _ in range(t):
	(n,) = R()
	arr = list(R())
	arr.sort()
	a = b = 0
	for i in arr:
		if i == a:
			a += 1
		elif b == i:
			b += 1
	print(a + b)


t = int(input())
for q in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	N = [0] * 101
	for i in l:
		N[i] += 1
	s = 0
	for i in range(101):
		if N[i] > 0:
			N[i] -= 1
		else:
			s = i
			break
	for i in range(101):
		if N[i] > 0:
			N[i] -= 1
		else:
			s = s + i
			break
	print(s)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().rstrip().split()))
	ct = [0] * 101
	for i in a:
		ct[i] += 1
	sb = -1
	sa = -1
	for i in range(101):
		if sa == -1 or sb == -1:
			if ct[i] == 0:
				if sa == -1:
					sa = i
				if sb == -1:
					sb = i
				continue
			if ct[i] < 2 and sb == -1:
				sb = i
		else:
			break
	print(sa + sb)


for i in range(int(input())):
	n = int(input())
	s = [0 for i in range(102)]
	for elem in list(map(int, input().split())):
		s[elem] += 1
	m = 0
	a = 0
	p = -1
	for elem in s:
		p += 1
		if elem == 0:
			if a == 0:
				m += p
			m += p
			break
		if elem == 1 and a == 0:
			m += p
			a = 1
	print(m)


for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	a = []
	b = []
	for num in arr:
		if num not in a:
			a.append(num)
		elif num not in b:
			b.append(num)
	a.sort()
	b.sort()
	ma = 0
	mb = 0
	for i in range(len(a)):
		if i != a[i]:
			ma = i
			break
		if i == len(a) - 1:
			ma = i + 1
	for i in range(len(b)):
		if i != b[i]:
			mb = i
			break
		if i == len(b) - 1:
			mb = i + 1
	print(ma + mb)


import sys
input = sys.stdin.readline
ins = lambda : input().rstrip()
ini = lambda : int(input().rstrip())
inm = lambda : map(int, input().rstrip().split())
inl = lambda : list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))
t = ini()
for _ in range(t):
	n = ini()
	a = inl()
	first = second = -1
	for i in range(101):
		if a.count(i) > 1:
			continue
		if a.count(i) == 1 and first == -1:
			first = i
			continue
		if a.count(i) == 0:
			first = i if first == -1 else first
			second = i
			break
	print(first + second)


import math
for _ in range(int(input())):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	a = 0
	b = 0
	for i in l:
		if a == i:
			a += 1
		elif b == i:
			b += 1
	print(a + b)


t = int(input())
for _ in range(t):
	n = int(input())
	lol = [int(n) for n in input().split()]
	l1 = []
	l2 = []
	ans = 0
	for i in lol:
		if i not in l1:
			l1.append(i)
		else:
			l2.append(i)
	if len(l1) > 0 and len(l2) > 0:
		for i in range(0, max(l1) + 2):
			if i not in l1:
				ans += i
				f = 1
				break
		for j in range(0, max(l2) + 2):
			if j not in l2:
				ans += j
				f = 1
				break
	if len(l1) == 0:
		for j in range(0, max(l2) + 2):
			if j not in l2:
				ans += j
				f = 1
				break
	if len(l2) == 0:
		for i in range(0, max(l1) + 2):
			if i not in l1:
				ans += i
				f = 1
				break
	print(ans)


def subset_mex(arr):
	s = list(set(arr))
	s.sort()
	a = []
	b = []
	min = 0
	for i in s:
		if arr.count(i) >= 2:
			a.append(i)
			b.append(i)
		else:
			a.append(i)
	if a:
		for i in range(max(a)):
			if i not in a:
				min += i
				break
		else:
			min += max(a) + 1
	if b:
		for i in range(max(b)):
			if i not in b:
				min += i
				break
		else:
			min += max(b) + 1
	return min
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	print(subset_mex(arr))


for _ in range(int(input())):
	n = int(input())
	l = [int(j) for j in input().split()]
	(a, b) = ([], [])
	f = [0] * 101
	for i in l:
		f[i] += 1
	for i in range(len(f)):
		if f[i] != 0:
			for j in range(f[i]):
				if j % 2 == 0:
					a.append(i)
				else:
					b.append(i)
	s = 0
	for i in range(101):
		if i not in a:
			s += i
			break
	for i in range(101):
		if i not in b:
			s += i
			break
	print(s)


t = int(input())
for index in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	cnt = [0 for i in range(102)]
	for i in range(n):
		cnt[arr[i]] += 1
	first = 0
	second = 0
	for i in range(102):
		if cnt[i] == 0:
			first = i
			break
	for i in range(102):
		if cnt[i] <= 1:
			second = i
			break
	print(first + second)


t = int(input())
while t > 0:
	n = int(input())
	ls = [int(x) for x in input().split()]
	js = []
	k = 0
	while k <= n:
		for i in range(len(ls)):
			if k == ls[i]:
				js.append(ls[i])
				ls.pop(i)
				break
		k = k + 1
	l = 0
	ls.sort()
	ls = list(dict.fromkeys(ls))
	for i in ls:
		if l != i:
			break
		l = l + 1
	m = 0
	for i in js:
		if m != i:
			break
		m = m + 1
	print(l + m)
	t = t - 1


mod = 1000000007
eps = 10 ** (-9)

def main():
	import sys
	from collections import Counter
	input = sys.stdin.readline
	for _ in range(int(input())):
		N = int(input())
		A = list(map(int, input().split()))
		C = Counter(A)
		ans = 0
		for i in range(101):
			if C[i] == 0:
				ans += i
				break
			else:
				C[i] -= 1
		for i in range(101):
			if C[i] == 0:
				ans += i
				break
		print(ans)
main()


def sid():
	f = 1
	for i in range(10):
		f = 0
	a = [1, 2]
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	c = {}
	for x in l:
		if x in c:
			c[x] += 1
		else:
			c[x] = 1
	ptr = 0
	ans = 0
	f = 0
	for (k, v) in c.items():
		if k == ptr and f == 0:
			if v == 1:
				ans += ptr
				f = 1
		elif k != ptr:
			break
		ptr += 1
	if f == 1:
		ans += ptr
	else:
		ans += 2 * ptr
	print(ans)


from sys import stdin, stdout
import math
import heapq
import collections
input = stdin.readline

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]

def inputstrings():
	return [x for x in input().split()]

def inputstringnum():
	return [ord(x) - ord('a') for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	n = inputnum()
	a = inputlist()
	a.sort()
	ans = 0
	ans1 = 0
	for i in range(n):
		if a[i] == ans:
			ans += 1
			a[i] = -1
	a.sort()
	for i in range(n):
		if a[i] == ans1:
			ans1 += 1
	print(ans + ans1)


def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	ans = {}
	for i in range(0, 101):
		ans[i] = arr.count(i)
	count = 0
	for key in ans.keys():
		if ans[key] == 0:
			count += key
			break
	for key in ans.keys():
		if ans[key] <= 1:
			count += key
			break
	print(count)
t = int(input())
for i in range(t):
	solve()


t = int(input())
for _ in range(t):
	n = int(input())
	x = [0] * 101
	for a in map(int, input().split()):
		x[a] += 1
	mA = 0
	while x[mA] > 0:
		mA += 1
	mB = 0
	while x[mB] > 1:
		mB += 1
	print(mA + mB)


import os
import sys
from io import BytesIO, IOBase
import threading
from bisect import bisect_right
from math import gcd, log
from collections import Counter
from pprint import pprint

def main():
	n = int(input())
	arr = list(map(int, input().split()))
	c = Counter(arr)
	x = 0
	while x in c and c[x] > 1:
		x += 1
	ans = x
	while x in c and c[x] > 0:
		x += 1
	ans += x
	print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	main()


import sys
t = int(input())
while t > 0:
	t -= 1
	n = int(sys.stdin.readline())
	input = sys.stdin.readline()
	arr = list(map(int, input.split()))
	mex1 = 0
	mex2 = 0
	index = [0 for i in range(n + 1)]
	for x in arr:
		if x <= n:
			index[x] += 1
	flag = 0
	for i in range(len(index)):
		if index[i] < 2:
			if index[i] == 1:
				if flag == 0:
					mex1 = i
					flag = 1
			elif index[i] == 0:
				if flag == 0:
					mex1 = i
					mex2 = i
				else:
					mex2 = i
				break
	print(mex1 + mex2)


from collections import defaultdict
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	count = defaultdict(int)
	for i in range(len(l)):
		count[l[i]] += 1
	l = set(l)
	mex = 0
	total = 0
	for i in range(max(l) + 2):
		if count[i] == 0 and total == 0:
			mex = 2 * i
			break
		elif count[i] == 1 and total == 0:
			mex += i
			total += 1
		elif count[i] == 0 and total == 1:
			mex += i
			total += 1
		if total == 2:
			break
	print(mex)


t = int(input())
for r in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	s = list(set(l))
	s.sort()
	w = []
	p = []
	a = []
	b = []
	y = 0
	c = 0
	if 0 not in l:
		c = 0
	else:
		for i in s:
			w.append(l.count(i))
			p.append(i)
		p.sort()
		for i in range(len(s)):
			if s[i] != i:
				y = i
				break
		e = list(set(w))
		if e[0] >= 3:
			e[0] = 2
		if len(e) == 1:
			if y != 0:
				c = y * e[0]
			else:
				c = (p[-1] + 1) * e[0]
		else:
			d = 0
			f = 0
			for i in range(len(p)):
				if w[i] == 1:
					a.append(p[i])
				else:
					a.append(p[i])
					b.append(p[i])
			for i in range(len(a)):
				if a[i] != i:
					d = i
					break
			a.sort()
			if d == 0 and 0 in a:
				c += a[-1] + 1
			else:
				c += d
			for i in range(len(b)):
				if b[i] != i:
					f = i
					break
			b.sort()
			if f == 0 and 0 in b:
				c += b[-1] + 1
			else:
				c += f
	print(c)


from collections import defaultdict
for _ in range(int(input())):
	d = defaultdict(int)
	n = int(input())
	a = list(map(int, input().split()))
	for i in a:
		d[i] += 1
	first = -1
	second = -1
	i = 0
	while True:
		if d[i] < 2:
			first = i
			if d[i] == 0:
				second = i
				break
			break
		i += 1
	if second == -1:
		while True:
			if d[i] == 0:
				second = i
				break
			i += 1
	print(first + second)


t = int(input())
for _ in range(t):
	n = int(input())
	freq = [0 for i in range(101)]
	arr = list(map(int, input().split()))
	for i in arr:
		freq[i] += 1
	ans = 0
	for i in range(101):
		if freq[i] == 0:
			ans += i
			break
		freq[i] -= 1
	for i in range(101):
		if freq[i] == 0:
			ans += i
			break
	print(ans)


import sys
input = sys.stdin.readline
from collections import Counter
t = int(input())
for tests in range(t):
	n = int(input())
	C = Counter(map(int, input().split()))
	X = 0
	Y = 0
	TWO = 1
	for i in range(200):
		if TWO == 1:
			if C[i] >= 2:
				X += 1
				Y += 1
			elif C[i] == 1:
				X += 1
				TWO = 0
			else:
				break
		elif C[i] >= 1:
			X += 1
		else:
			break
	print(X + Y)


for _ in range(int(input())):
	n = int(input())
	li = sorted(list(map(int, input().split())))
	(x, y) = (0, 0)
	for i in li:
		if x == i:
			x += 1
		elif y == i:
			y += 1
	print(x + y)


def Test():
	t = int(input())
	while t > 0:
		t -= 1
		soln()

def soln():
	n = int(input())
	a = list(map(int, input().strip().split(' ')))
	dic = {}
	for i in range(n):
		if a[i] in dic:
			dic[a[i]] += 1
		else:
			dic[a[i]] = 1
	ex = 0
	f1 = 0
	f2 = 0
	l1 = -1
	l2 = -1
	for i in sorted(dic.keys()):
		if ex != i:
			l2 = ex
			f2 = 1
			break
		else:
			ex += 1
			if dic[i] == 1 and f1 == 0:
				l1 = i
				f1 = 1
	ans = -1
	if f2 == 0:
		l2 = ex
	if f1 == 0:
		ans = 2 * l2
	else:
		ans = max(l2, l1 + l2)
	print(ans)
Test()


w = int(input())
for a in range(w):
	ok1 = True
	ok2 = True
	mexA = 0
	mexB = 0
	x = int(input())
	l = list(map(int, input().split()))
	for i in range(x):
		if i in l:
			mexA = i + 1
			l.remove(i)
			if ok1:
				if i in l:
					mexB = i + 1
				else:
					resultB = i
					ok1 = False
		else:
			resultA = i
			ok2 = False
			break
	if ok1:
		resulB = mexB
	if ok2:
		resultA = mexA
	print(mexA + mexB)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	l1 = []
	l2 = []
	for i in range(n):
		if l[i] in l1:
			l2.append(l[i])
		else:
			l1.append(l[i])
	l1.sort()
	l2.sort()
	ans = 0
	for i in range(101):
		if i not in l1:
			ans += i
			break
	for i in range(101):
		if i not in l2:
			ans += i
			break
	print(ans)


for _ in range(int(input())):
	freq = [0] * 101
	n = int(input())
	arr = list(map(int, input().split()))
	for val in arr:
		freq[val] += 1
	ans = 0
	cnt = 2
	for x in range(101):
		if freq[x] == 0:
			ans += x
			break
		else:
			freq[x] -= 1
	for x in range(101):
		if freq[x] == 0:
			ans += x
			break
		else:
			freq[x] -= 1
	print(ans)


def mi():
	return map(int, input().split())
for _ in range(int(input())):
	n = int(input())
	a = list(mi())
	cnt = [0] * 102
	for i in a:
		cnt[i] += 1
	i = 0
	while i <= 100 and cnt[i]:
		cnt[i] -= 1
		i += 1
	ans = i
	i = 0
	while i <= 100 and cnt[i]:
		cnt[i] -= 1
		i += 1
	ans += i
	print(ans)


for s in [*open(0)][2::2]:
	a = b = 0
	for i in sorted(map(int, s.split())):
		if i == a:
			a += 1
		else:
			b += i == b
	print(a + b)


def mex(S):
	Sset = set(S)
	for i in range(len(S) + 1):
		if i not in Sset:
			return i
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	A = set()
	B = []
	for num in arr:
		if num not in A:
			A.add(num)
		else:
			B.append(num)
	result = mex(A) + mex(B)
	print(result)


def segregate(arr, size):
	j = 0
	for i in range(size):
		if arr[i] <= 0:
			(arr[i], arr[j]) = (arr[j], arr[i])
			j += 1
	return j

def findMissingPositive(arr, size):
	for i in range(size):
		if abs(arr[i]) - 1 < size and arr[abs(arr[i]) - 1] > 0:
			arr[abs(arr[i]) - 1] = -arr[abs(arr[i]) - 1]
	for i in range(size):
		if arr[i] > 0:
			return i + 1
	return size + 1

def findMissing(arr, size):
	shift = segregate(arr, size)
	if 0 not in arr:
		return 0
	if arr == []:
		return 0
	return findMissingPositive(arr[shift:], size - shift)
t = int(input())
for p in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	A = set()
	B = set()
	a.sort()
	for i in range(n):
		if a[i] not in A:
			A.add(a[i])
		else:
			B.add(a[i])
	A = list(A)
	B = list(B)
	print(findMissing(A, len(A)) + findMissing(B, len(B)))


import sys
readline = sys.stdin.readline
INF = 1 << 60

def read_int():
	return int(readline())

def read_int_n():
	return list(map(int, readline().split()))

def read_float():
	return float(readline())

def read_float_n():
	return list(map(float, readline().split()))

def read_str():
	return readline().strip()

def read_str_n():
	return readline().strip().split()

def ep(*args):
	print(*args, file=sys.stderr)

def mt(f):
	import time

	def wrap(*args, **kwargs):
		s = time.perf_counter()
		ret = f(*args, **kwargs)
		e = time.perf_counter()
		ep(e - s, 'sec')
		return ret
	return wrap
from collections import Counter

def slv(N, A):
	c = Counter(A)
	for i in range(10000):
		if c[i] < 2:
			a = i
			break
	for i in range(10000):
		if c[i] < 1:
			b = i
			break
	return a + b

def main():
	for _ in range(read_int()):
		N = read_int()
		A = read_int_n()
		print(slv(N, A))
main()


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	c = Counter(a)
	i = 0
	while c[i] != 0:
		c[i] -= 1
		i += 1
	s = i
	j = 0
	while c[j] != 0:
		c[j] -= 1
		j += 1
	s += j
	print(s)


import sys
import string
import math
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache
from fractions import Fraction

def mi(s):
	return map(int, s.strip().split())

def lmi(s):
	return list(mi(s))

def tmi(s):
	return tuple(mi(s))

def mf(f, s):
	return map(f, s)

def lmf(f, s):
	return list(mf(f, s))

def js(lst):
	return ' '.join((str(d) for d in lst))

def jsns(lst):
	return ''.join((str(d) for d in lst))

def line():
	return sys.stdin.readline().strip()

def linesp():
	return line().split()

def iline():
	return int(line())

def mat(n):
	matr = []
	for _ in range(n):
		matr.append(linesp())
	return matr

def matns(n):
	mat = []
	for _ in range(n):
		mat.append([c for c in line()])
	return mat

def mati(n):
	mat = []
	for _ in range(n):
		mat.append(lmi(line()))
	return mat

def pmat(mat):
	for row in mat:
		print(js(row))

def solve():
	line()
	arr = lmi(line())
	counts = Counter(arr)
	i = 0
	j = 0
	while True:
		noj = True
		noi = True
		if counts[i] >= 1:
			counts[i] -= 1
			i += 1
			noi = False
		if counts[j] >= 1:
			counts[j] -= 1
			j += 1
			noj = False
		if noi and noj:
			break
	print(i + j)

def main():
	t = iline()
	for _ in range(t):
		solve()
main()


import io
import os
from collections import Counter, defaultdict, deque

def solve(N, A):
	freq = Counter(A)
	mex1 = 0
	mex2 = 0
	for i in range(max(A) + 2):
		if freq[i] >= 2 and mex2 == i:
			mex2 = i + 1
		if freq[i] >= 1 and mex1 == i:
			mex1 = i + 1
	return mex1 + mex2
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
TC = int(input())
for tc in range(1, TC + 1):
	(N,) = [int(x) for x in input().split()]
	A = [int(x) for x in input().split()]
	ans = solve(N, A)
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	x = [int(i) for i in input().split()]
	c = [0 for i in range(102)]
	for i in range(len(x)):
		c[x[i]] += 1
	mex1 = mex2 = -1
	for i in range(102):
		if c[i] == 0 and mex1 == -1:
			mex1 = i
			mex2 = i
			break
		elif c[i] == 0:
			mex2 = i
			break
		elif c[i] == 1 and mex1 == -1:
			mex1 = i
			continue
		elif c[i] == 1:
			continue
		else:
			continue
	print(mex1 + mex2)


for _ in range(int(input())):
	input()
	w = sorted(map(int, input().split()))
	s = set(w)
	a = 0
	c = 0
	for i in s:
		if i == a:
			a += 1
		else:
			c = a
			a = 0
			break
	else:
		c = a
		a = 0
	for i in w:
		if w.count(a) >= 2:
			a += 1
		else:
			c += a
			break
	else:
		c += a
	print(c)


def mex(N, S):
	c = 0
	ans = 0
	for i in range(102):
		if S.count(i) == 0:
			ans += i * (2 - c)
			break
		elif S.count(i) == 1:
			if c == 0:
				ans += i
				c += 1
	return ans
for i in range(int(input())):
	print(mex(int(input()), list(map(int, input().split()))))


t = int(input())
for i in range(t):
	n = int(input())
	list1 = []
	list2 = []
	x = input()
	s = x.split()
	for j in s:
		k = int(j)
		if k not in list1:
			list1.append(k)
		else:
			list2.append(k)
	max = 0
	for j in range(101):
		if j not in list1:
			max += j
			break
	if len(list2) > 0:
		for j in range(101):
			if j not in list2:
				max += j
				break
	print(max)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))

	def mex(l):
		i = 0
		a = []
		while i < n + 1:
			if i in l:
				a.append(i)
				l.remove(i)
				i += 1
			else:
				return i
	r1 = mex(l)
	r2 = mex(l)
	print(r1 + r2)


from functools import cmp_to_key
from collections import deque, Counter
from heapq import heappush, heappop
from math import log, ceil
import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def ii():
	return int(inp())

def si():
	return str(inp())

def li(lag=0):
	l = list(map(int, inp().split()))
	if lag != 0:
		for i in range(len(l)):
			l[i] += lag
	return l

def mi(lag=0):
	matrix = list()
	for i in range(n):
		matrix.append(li(lag))
	return matrix

def lsi():
	return list(map(str, inp().split()))

def print_list(lista, space=' '):
	print(space.join(map(str, lista)))

def bisect_left(a, x):
	left = 0
	right = len(a)
	while left < right:
		mid = (left + right) // 2
		if a[mid] < x:
			left = mid + 1
		else:
			right = mid
	return left

def bisect_right(a, x):
	left = 0
	right = len(a)
	while left < right:
		mid = (left + right) // 2
		if a[mid] > x:
			right = mid
		else:
			left = mid + 1
	return left

def bisect_elements(a, x):
	return bisect_right(a, x) - bisect_left(a, x)
MOD = 10 ** 9 + 7
maxN = 5
FACT = [0] * maxN
INV_FACT = [0] * maxN

def add(x, y):
	return (x + y) % MOD

def multiply(x, y):
	return x * y % MOD

def power(x, y):
	if y == 0:
		return 1
	elif y % 2:
		return multiply(x, power(x, y - 1))
	else:
		a = power(x, y // 2)
		return multiply(a, a)

def inverse(x):
	return power(x, MOD - 2)

def divide(x, y):
	return multiply(x, inverse(y))

def allFactorials():
	FACT[0] = 1
	for i in range(1, maxN):
		FACT[i] = multiply(i, FACT[i - 1])

def inverseFactorials():
	n = len(INV_FACT)
	INV_FACT[n - 1] = inverse(FACT[n - 1])
	for i in range(n - 2, -1, -1):
		INV_FACT[i] = multiply(INV_FACT[i + 1], i + 1)

def coeffBinom(n, k):
	if n < k:
		return 0
	return multiply(FACT[n], multiply(INV_FACT[k], INV_FACT[n - k]))

def create_graph(n, m, undirected=1, unweighted=1):
	graph = [[] for i in range(n)]
	if unweighted:
		for i in range(m):
			[x, y] = li(lag=-1)
			graph[x].append(y)
			if undirected:
				graph[y].append(x)
	else:
		for i in range(m):
			[x, y, w] = li(lag=-1)
			w += 1
			graph[x].append([y, w])
			if undirected:
				graph[y].append([x, w])
	return graph

def create_tree(n, unweighted=1):
	children = [[] for i in range(n)]
	if unweighted:
		for i in range(n - 1):
			[x, y] = li(lag=-1)
			children[x].append(y)
			children[y].append(x)
	else:
		for i in range(n - 1):
			[x, y, w] = li(lag=-1)
			w += 1
			children[x].append([y, w])
			children[y].append([x, w])
	return children

def dist(tree, n, A, B=-1):
	s = [[A, 0]]
	(massimo, massimo_nodo) = (0, 0)
	distanza = -1
	v = [-1] * n
	while s:
		(el, dis) = s.pop()
		if dis > massimo:
			massimo = dis
			massimo_nodo = el
		if el == B:
			distanza = dis
		for child in tree[el]:
			if v[child] == -1:
				v[child] = 1
				s.append([child, dis + 1])
	return (massimo, massimo_nodo, distanza)

def diameter(tree):
	(_, foglia, _) = dist(tree, n, 0)
	(diam, _, _) = dist(tree, n, foglia)
	return diam

def dfs(graph, n, A):
	v = [-1] * n
	s = [[A, 0]]
	v[A] = 0
	while s:
		(el, dis) = s.pop()
		for child in graph[el]:
			if v[child] == -1:
				v[child] = dis + 1
				s.append([child, dis + 1])
	return v

def bfs(graph, n, A):
	v = [-1] * n
	s = deque()
	s.append([A, 0])
	v[A] = 0
	while s:
		(el, dis) = s.popleft()
		for child in graph[el]:
			if v[child] == -1:
				v[child] = dis + 1
				s.append([child, dis + 1])
	return v

def parents_children_root_unrooted_tree(tree, n, root=0):
	q = deque()
	visited = [0] * n
	parent = [-1] * n
	children = [[] for i in range(n)]
	q.append(root)
	while q:
		all_done = 1
		visited[q[0]] = 1
		for child in tree[q[0]]:
			if not visited[child]:
				all_done = 0
				q.appendleft(child)
		if all_done:
			for child in tree[q[0]]:
				if parent[child] == -1:
					parent[q[0]] = child
					children[child].append(q[0])
			q.popleft()
	return (parent, children)

def all_longest_path_passing_from_node(parent, children, n):
	q = deque()
	visited = [len(children[i]) for i in range(n)]
	downwards = [[0, 0] for i in range(n)]
	upward = [1] * n
	longest_path = [1] * n
	for i in range(n):
		if not visited[i]:
			q.append(i)
			downwards[i] = [1, 0]
	while q:
		node = q.popleft()
		if parent[node] != -1:
			visited[parent[node]] -= 1
			if not visited[parent[node]]:
				q.append(parent[node])
		else:
			root = node
		for child in children[node]:
			downwards[node] = sorted([downwards[node][0], downwards[node][1], downwards[child][0] + 1], reverse=True)[0:2]
	s = [node]
	while s:
		node = s.pop()
		if parent[node] != -1:
			if downwards[parent[node]][0] == downwards[node][0] + 1:
				upward[node] = 1 + max(upward[parent[node]], downwards[parent[node]][1])
			else:
				upward[node] = 1 + max(upward[parent[node]], downwards[parent[node]][0])
		longest_path[node] = downwards[node][0] + downwards[node][1] + upward[node] - min([downwards[node][0], downwards[node][1], upward[node]]) - 1
		for child in children[node]:
			s.append(child)
	return longest_path
for test in range(ii()):
	n = ii()
	a = li()
	a = sorted(a)
	occ = [0 for i in range(n + 1)]
	for i in range(n):
		if a[i] >= 0 and a[i] <= n:
			occ[a[i]] += 1
	messo = 0
	s = 0
	i = 0
	while i <= n and messo < 2:
		if occ[i] == 0:
			s += (2 - messo) * i
			messo = 2
		elif occ[i] == 1 and messo == 0:
			s += i
			messo += 1
		i += 1
	print(s)


for s in [*open(0)][2::2]:
	a = [0] * 102 + [1]
	for x in s.split():
		a[int(x)] += 1
	i = a.index(0)
	print(i + min(i, a.index(1)))


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	cnt = []
	res = 0
	for i in range(101):
		cnt.append(arr.count(i))
	for i in range(101):
		if cnt[i] == 0:
			res += i
			break
	for i in range(101):
		if cnt[i] <= 1:
			res += i
			break
	print(res)


t = int(input())
for _ in range(t):
	n = int(input())
	a = sorted([int(s) for s in input().split()])
	a1 = 0
	b1 = 0
	i = 0
	while i in a:
		a.remove(i)
		a1 += 1
		i += 1
	i = 0
	while i in a:
		a.remove(i)
		b1 += 1
		i += 1
	print(a1 + b1)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	i = 0
	while i in l:
		l.remove(i)
		i += 1
	j = 0
	while j in l:
		l.remove(j)
		j += 1
	print(i + j)


cases = int(input())
while cases:
	cases -= 1
	num = int(input())
	arr = list(map(int, input().split()))
	st1 = -1
	st2 = -1
	broken = False
	for i in range(101):
		if i not in arr:
			break
		elif arr.count(i) > 1 and (not broken):
			st1 += 1
			st2 += 1
		else:
			st1 += 1
			broken = True
	print(2 + st1 + st2)


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		A = [int(x) for x in input().split()]
		default = dict([(i, 0) for i in range(101)])
		for ele in A:
			default[ele] += 1
		ans = 0
		count = 0
		one_occur = False
		for k in default:
			if default[k] == 0 and count < 2:
				ans += k
				count += 1
				if count < 2:
					ans += k
					count += 1
			elif default[k] == 1 and count < 2 and (not one_occur):
				ans += k
				count += 1
				one_occur = True
			if count > 2:
				break
		print(ans)
main()


def find_a_b(l1):
	find_a = 0
	a = 0
	find_b = 0
	b = 0
	while True:
		if l1.count(find_a) == 0:
			a = find_a
			break
		find_a += 1
	while True:
		if l1.count(find_b) <= 1:
			b = find_b
			break
		find_b += 1
	return (a, b)
number_of_test = int(input())
output_array = []
for i in range(number_of_test):
	loose = input()
	l1 = list(map(int, input().split()))
	(a, b) = find_a_b(l1)
	output_array.append(a + b)
for j in output_array:
	print(j)


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	(a, b) = (0, 0)
	for i in s:
		if a == i:
			a += 1
		elif b == i:
			b += 1
	print(a + b)


n = int(input())
for i in range(n):
	m = int(input())
	list1 = list(map(int, input().split()))
	list2 = []
	for j in range(101):
		list2.append(list1.count(j))
	if list2[0] == 0:
		print('0')
	else:
		res1 = list2.index(0)
		for i in range(res1):
			list2[i] = list2[i] - 1
		res2 = list2.index(0)
		print(res1 + res2)


t = int(input())
for _ in range(t):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	list1 = []
	list2 = []
	for items in a:
		if items not in list1:
			list1.append(items)
		elif items not in list2:
			list2.append(items)
	x = -1
	for i in range(0, len(list1)):
		x += 1
		if list1[i] != x:
			break
	if i == len(list1) - 1:
		if x == list1[i]:
			x += 1
	y = -1
	if len(list2) == 0:
		y = 0
	else:
		for i in range(0, len(list2)):
			y += 1
			if list2[i] != y:
				break
	if i == len(list2) - 1:
		if y == list2[i]:
			y += 1
	print(x + y)


USE_FILE = False
FILE = None
if USE_FILE:
	FILE = open('input.txt')

def rline():
	return (FILE.readline() if USE_FILE else input()).split()

def readint():
	return int(rline()[0])

def sum2(l, r):
	return (l + r) // 2 * ((r - l) // 2 + 1)

def solve():
	n = readint()
	line = rline()
	all = [int(x) for x in line]
	cnt = {}
	for x in all:
		if x not in cnt:
			cnt[x] = 1
		else:
			cnt[x] += 1
	res = 0
	remain = 2
	for i in range(103):
		if i not in cnt:
			if remain == 2:
				return i * 2
			else:
				return res + i
		if cnt[i] < remain:
			res = i
			remain -= 1
	return res
t = int(rline()[0])
for z in range(t):
	res = solve()
	print(res)


z = int(input())
for i in range(z):
	x = int(input())
	a = input().split()
	A = []
	B = []
	check = 'yes'
	acheck = 'yes'
	bcheck = 'yes'
	c = 0
	while check == 'yes':
		if acheck == 'yes':
			if str(c) in a:
				A.append(c)
				a.remove(str(c))
			else:
				acheck = 'no'
				d = 0
				d += c
		if bcheck == 'yes':
			if str(c) in a:
				B.append(c)
				a.remove(str(c))
			else:
				bcheck = 'no'
				e = 0
				e += c
		c += 1
		if bcheck == 'no' and acheck == 'no':
			check = 'no'
	print(e + d)


from collections import Counter
for _ in range(int(input())):
	N = int(input())
	X = sorted(list(map(int, input().split())))
	Answer = []
	MyDict = Counter(X)
	Check = True
	Index = 0
	while True:
		if len(Answer) == 0 and MyDict.get(Index) == None:
			Answer.append(Index)
			Answer.append(Index)
			break
		elif len(Answer) == 1 and MyDict.get(Index) == None:
			Answer.append(Index)
			break
		elif MyDict.get(Index) == 1 and Check:
			Answer.append(Index)
			Check = False
		Index += 1
	print(sum(Answer))


import sys
import itertools
import math
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(m,) = I()
while m:
	(n,) = I()
	arr = I()
	g = [0] * (max(arr) + 2)
	for i in range(n):
		g[arr[i]] += 1
	ma = c = key = 0
	for i in range(len(g)):
		if g[i] == 0 and c < 2:
			c += 1
			ma += i
			break
	for i in range(len(g)):
		if g[i] < 2 and c < 2:
			c += 1
			ma += i
			break
	print(ma)
	m -= 1


def main():
	trials = input()
	for i in range(int(trials)):
		input()
		nums = [int(n) for n in input().split()]
		l_open = 2
		mex_sum = 0
		for j in range(max(nums) + 2):
			if nums.count(j) < l_open:
				mex_sum += j * (l_open - nums.count(j))
				l_open = nums.count(j)
			if l_open == 0:
				break
		print(mex_sum)
main()


test = int(input())
for _ in range(test):
	n = int(input())
	arr = list(map(int, input().split()))
	temp = [0] * 101
	for i in arr:
		temp[i] += 1
	i = temp.index(0)
	temp[i] = 1
	print(i + temp.index(1))


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	m = 0
	a = []
	b = []
	for i in l:
		if i not in a:
			a.append(i)
		else:
			b.append(i)
	if len(a) > 0:
		for i in range(max(a) + 2):
			if i not in a:
				x = i
				break
	else:
		x = 0
	if len(b) > 0:
		for i in range(max(b) + 2):
			if i not in b:
				y = i
				break
	else:
		y = 0
	print(x + y)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	if min(a) == 0:
		i = 0
		while i in a:
			i += 1
		ans = i
		cov = [0] * i
		b = []
		for i in a:
			if i < ans:
				if cov[i]:
					b.append(i)
				else:
					cov[i] = 1
			else:
				b.append(i)
		i = 0
		while i in b:
			i += 1
		ans += i
		print(ans)
	else:
		print(0)


def mex(a):
	k = 0
	for i in range(1000):
		if a.count(i) == 0:
			k += i
			break
	for i in range(1000):
		if a.count(i) <= 1:
			k += i
			break
	return k
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	print(mex(a))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = [0] * 101
	for i in a:
		b[i] += 1
	flag = False
	ans = 0
	for i in range(101):
		if b[i] == 1 and flag == False:
			ans += i
			flag = True
		elif b[i] == 0:
			if flag == False:
				print(i * 2)
			else:
				print(ans + i)
			break


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
from decimal import *
BUFSIZE = 8192
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		cnt = [0] * 101
		for x in a:
			cnt[x] += 1
		ans = 0
		for j in range(len(cnt)):
			if cnt[j] == 0:
				ans += j
				break
			cnt[j] -= 1
		for j in range(len(cnt)):
			if cnt[j] == 0:
				ans += j
				break
			cnt[j] -= 1
		print(ans)
main()


for _ in range(int(input())):
	(n, a) = (int(input()), sorted([int(x) for x in input().split()]))
	v = 0
	i = 0
	for row in set(a):
		if row == i:
			if a.count(row) >= 2 and row == v:
				v += 1
				i += 1
			else:
				i += 1
	print(v + i)


t = int(input())
for ex in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	num = 0
	while a.count(num) >= 2:
		num += 1
	m1 = num
	while a.count(num) >= 1:
		num += 1
	m2 = num
	print(m1 + m2)


import sys
from copy import *
from bisect import *

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')
di = [[-1, 0], [1, 0], [0, 1], [0, -1]]

def inc(d, c, x=1):
	d[c] = d[c] + x if c in d else x

def bo(i):
	return ord(i) - ord('A')

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for xx in input().split()]

def fi():
	return int(input())

def pro(a):
	return reduce(lambda a, b: a * b, a)

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def gh():
	sys.stdout.flush()

def isvalid(i, j):
	return 0 <= i < n and 0 <= j < m and (a[i][j] != '.')

def bo(i):
	return ord(i) - ord('a')

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)
t = fi()
while t > 0:
	t -= 1
	n = fi()
	a = li()
	d = [0] * (100 + 2)
	ans = 0
	for i in range(n):
		d[a[i]] += 1
	for i in range(n + 2):
		if d[i] == 1:
			ans += i
			for j in range(i + 1, n + 2):
				if d[j] == 0:
					ans += j
					break
			break
		elif d[i] == 0:
			ans += 2 * i
			break
	print(ans)


for _ in range(int(input())):
	r = int(input())
	arr = list(map(int, input().split()))
	(a, b) = (0, 0)
	arr.sort()
	for i in arr:
		if a == i:
			a += 1
		elif b == i:
			b += 1
	print(a + b)


def read_int():
	return int(input())

def read_ints():
	return list(map(int, input().split(' ')))
t = read_int()
for case_num in range(t):
	n = read_int()
	a = list(read_ints())
	cnt = [0 for _ in range(101)]
	for i in a:
		cnt[i] += 1
	ans = 0
	status = 2
	for i in range(101):
		status = min(status, cnt[i])
		if status == 0:
			break
		ans += status
	print(ans)


from collections import Counter

def solve(a):
	c = Counter(a)
	first = 0
	m = max(a)
	hello = False
	for i in range(m + 1):
		if c[i] == 0:
			first = i
			hello = True
			break
		else:
			c[i] -= 1
	if not hello:
		first = m + 1
	hello = False
	ans = []
	for v in c:
		if c[v]:
			ans.append(v)
	ans.sort()
	second = 0
	for i in range(m + 1):
		if i not in ans:
			second = i
			hello = True
			break
	if not hello:
		second = m + 1
	print(first + second)
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	solve(a)


import os
from sys import stdin, stdout

def solve(tc):
	n = int(stdin.readline().strip())
	seq = list(map(int, stdin.readline().split()))
	nums = [0 for i in range(101)]
	for i in range(n):
		nums[seq[i]] += 1
	ans = 0
	for i in range(101):
		if nums[i]:
			nums[i] -= 1
		else:
			ans += i
			break
	for i in range(101):
		if nums[i]:
			nums[i] -= 1
		else:
			ans += i
			break
	print(ans)
tcs = 1
tcs = int(stdin.readline().strip())
tc = 1
while tc <= tcs:
	solve(tc)
	tc += 1


from sys import stdin
from collections import Counter
N = int(stdin.readline())
for case in range(N):
	length = int(stdin.readline())
	array = [int(i) for i in stdin.readline().split()]
	mexa = 0
	mexb = 0
	count = Counter(array)
	for i in range(101):
		if count[i] > 0:
			count[i] -= 1
			continue
		else:
			mexa = i
			break
	for i in range(101):
		if count[i] == 0:
			mexb = i
			break
	print(mexa + mexb)


t = int(input())
for _ in range(t):
	n = int(input())
	(*a,) = map(int, input().split())
	cnt = [0] * 101
	for aa in a:
		cnt[aa] += 1
	first = 0
	for i in range(101):
		if cnt[i] == 0:
			break
		cnt[i] -= 1
		first += 1
	second = 0
	for i in range(101):
		if cnt[i] == 0:
			break
		second += 1
	print(first + second)


import sys, math
try:
	(sys.stdin, sys.stdout) = (open('input.txt', 'r'), open('out.txt', 'w'))
except:
	pass
from sys import stdin, stdout
mod = int(1000000000.0 + 7)
from statistics import mode
from collections import *
from math import ceil, floor, inf, factorial, gcd, log2, sqrt, log
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()

def lcm(a, b):
	return a * b // gcd(a, b)

def setbits(n):
	return bin(n).count('1')

def resetbits(n):
	return bin(n).count('0')

def modinv(n, p):
	return pow(n, p - 2, p)

def ncr(n, r):
	(num, den) = (1, 1)
	r = min(n, n - r)
	for i in range(r):
		num *= n - i
		den *= i + 1
	return num // den

def ncr_p(n, r, p):
	(num, den) = (1, 1)
	r = min(r, n - r)
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * modinv(den, p) % p

def isPrime(num):
	if num <= 1:
		return False
	if num == 2 or n == 3:
		return True
	if num % 2 == 0 or num % 3 == 0:
		return False
	m = int(num ** 0.5) + 1
	for i in range(5, m, 6):
		if num % i == 0 or num % (i + 2) == 0:
			return False
	return True

def bin_search(s, low, high, val):
	while low <= high:
		mid = low + (high - low) // 2
		if s[mid] == val:
			return mid
		elif s[mid] < val:
			low = mid + 1
		else:
			high = mid - 1
	return -1

def sumofdigit(num):
	count = 0
	while num:
		count += num % 10
		num //= 10
	return count

def inputmatrix():
	(r, c) = iia()
	mat = [0] * r
	for i in range(r):
		mat[i] = iia()
	return (r, c, mat)

def prefix_sum(n, s):
	for i in range(1, n):
		s[i] += s[i - 1]
	return s

def binomial(n, k):
	if 0 <= k <= n:
		ntok = 1
		ktok = 1
		for t in range(1, min(k, n - k) + 1):
			ntok *= n
			ktok *= t
			n -= 1
		return ntok // ktok
	else:
		return 0

def divisors(n):
	res = []
	for i in range(1, ceil(sqrt(n)) + 1):
		if n % i == 0:
			if i == n // i:
				res.append(i)
			else:
				res.append(i)
				res.append(n // i)
	return res
for _ in range(ii1()):
	n = ii1()
	arr = iia()
	a = Counter(arr)
	first = []
	second = []
	for (key, val) in a.items():
		if val == 1:
			first.append(key)
		elif val >= 2:
			first.append(key)
			second.append(key)
	first.sort()
	second.sort()
	ans = 0
	flag = False
	for i in range(len(first)):
		if first[i] != i:
			ans += i
			flag = True
			break
	if flag == False:
		ans += len(first)
	flag = False
	for i in range(len(second)):
		if second[i] != i:
			ans += i
			flag = True
			break
	if flag == False:
		ans += len(second)
	print(ans)


def main():
	n = int(input())
	numbers = list(map(int, input().split()))
	mx = max(numbers)
	d = dict()
	first = -1
	second = -1
	first_stop = False
	for n in numbers:
		d[n] = d.get(n, 0) + 1
	i = 0
	while mx >= i:
		if i not in d:
			break
		elif d[i] >= 2:
			if not first_stop:
				first = i
			second = i
		elif d[i] == 1:
			second = i
			first_stop = True
		i += 1
	print(first + second + 2)
for _ in range(int(input())):
	main()


T = int(input())
while T:
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	b = []
	c = []
	if a[0] != 0:
		print('0')
	else:
		b = list(set(a))
		b.sort()
		f = x = y = 0
		for i in range(len(b)):
			if i not in b:
				x = i
				f = 1
				break
		if f == 0:
			x = b[-1] + 1
		for i in b:
			a.remove(i)
		f = 0
		for i in range(len(a)):
			if i not in a:
				y = i
				f = 1
				break
		if f == 0:
			if len(a) > 0:
				y = a[-1] + 1
		print(x + y)
	T -= 1


h = int(input())
l = []
for i in range(h):
	y = int(input())
	x = list(map(int, input().split()))
	if y == 1:
		if x[0] == 0:
			l.append(1)
		else:
			l.append(0)
		continue
	x.sort()
	sum = 0
	A = []
	B = []
	n = None
	s = x[0]
	if s == 0:
		for i in range(len(x)):
			if x[i] == n:
				if i == len(x) - 1:
					sum += s
				else:
					continue
			elif x[i] > s:
				sum += s
				break
			else:
				A.append(x[i])
				B.append(x[i])
				n = x[i]
				s += 1
				if i == len(x) - 1:
					sum += s
	A = []
	if len(B) != y:
		n = None
		s = x[0]
		if s == 0:
			for i in range(len(x)):
				if x[i] == n:
					if i == len(x) - 1:
						sum += s
					else:
						continue
				elif x[i] > s:
					sum += s
					break
				elif x[i] in B:
					B.remove(x[i])
					if i == len(x) - 1:
						sum += s
				else:
					A.append(x[i])
					n = x[i]
					s += 1
					if i == len(x) - 1:
						sum += s
	l.append(sum)
for i in l:
	print(i)


for _ in range(int(input())):
	n = int(input())
	a = [*map(int, input().split())]
	(ans, tmp) = (0, 2)
	count = [0] * 200
	for i in a:
		count[i] += 1
	for i in count:
		tmp = min(tmp, i)
		ans += tmp
	print(ans)


for _ in range(int(input())):
	n = int(input())
	mxa = mxb = 0
	for i in sorted(map(int, input().split())):
		if i == mxa:
			mxa += 1
		elif i == mxb:
			mxb += 1
	print(mxa + mxb)


for t in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	m = arr[-1]
	l = [0] * (m + 1)
	for i in set(arr):
		l[i] = arr.count(i)
	x = []
	y = []
	for i in range(len(l)):
		for j in range(l[i] // 2):
			x.append(i)
			y.append(i)
		if l[i] % 2 != 0:
			x.append(i)
	(ans1, ans2) = (-1, -1)
	x = list(set(x))
	y = list(set(y))
	for i in range(len(x)):
		if x[i] != i:
			ans1 = i
			break
	if ans1 == -1:
		if len(x) >= 1:
			ans1 = x[-1] + 1
		else:
			ans1 = 0
	for i in range(len(y)):
		if y[i] != i:
			ans2 = i
			break
	if ans2 == -1:
		if len(y) >= 1:
			ans2 = y[-1] + 1
		else:
			ans2 = 0
	print(ans1 + ans2)


import sys

def multiple_input():
	return map(int, sys.stdin.readline().strip().split())

def list_input():
	return list(map(int, sys.stdin.readline().strip().split()))
for _ in range(int(input())):
	n = int(input())
	a = list_input()
	a.sort()
	(x, y) = (-1, -1)
	(ans1, ans2) = (0, 0)
	for i in a:
		if i - x == 1:
			x = i
		elif i - x == 0:
			if i - y == 1:
				y = i
		else:
			break
	print(x + y + 2)


test = int(input())
for i in range(0, test):
	n = int(input())
	s = [int(i) for i in input().split(' ')]
	c = []
	for i in range(0, 102):
		c.append(0)
	for e in s:
		c[e] += 1
	oi = -1
	zi = -1
	for i in range(0, 102):
		if c[i] == 1:
			oi = i
			break
	for i in range(0, 102):
		if c[i] == 0:
			zi = i
			break
	if oi == -1:
		print(2 * zi)
	elif zi < oi:
		print(2 * zi)
	else:
		print(zi + oi)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ch = [0 for i in range(101)]
	for el in a:
		ch[el] += 1
	i = 0
	while ch[i] >= 2:
		i += 1
	x = i
	while ch[i] >= 1:
		i += 1
	print(x + i)


import math
test = int(input())
for t in range(test):
	n = int(input())
	A = list(map(int, input().split()))
	A.sort()
	cnt = [0 for i in range(101)]
	for i in A:
		cnt[i] += 1
	ans1 = -1
	ans2 = -1
	p = 0
	for i in range(101):
		if cnt[p] == 0:
			ans1 = p
			break
		p += 1
	p = 0
	for i in range(101):
		if cnt[p] == 1 or cnt[p] == 0:
			ans2 = p
			break
		p += 1
	print(ans1 + ans2)


numeroTestes = int(input())
for i in range(numeroTestes):
	int(input())
	aux = 0
	vector = []
	countVector = [0] * 101
	for i in input().split():
		countVector[int(i)] += 1
	for i in range(101):
		if countVector[i] != 0:
			countVector[i] -= 1
		else:
			aux += i
			break
	for i in range(101):
		if countVector[i] != 0:
			countVector[i] -= 1
		else:
			aux += i
			break
	print(aux)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	val = 0
	a = list(set(arr))
	a.sort()
	count = 0
	for i in range(n + 1):
		if i not in a:
			val += (2 - count) * i
			break
		elif i in a:
			if arr.count(i) < 2 - count:
				val += i
				count += 1
				if count == 2:
					break
	print(val)


from collections import Counter
for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	used = [0] * n
	pa = -1
	pb = -1
	for j in range(n):
		if arr[j] == pa + 1:
			pa = arr[j]
			used[j] = 1
	for j in range(n):
		if arr[j] == pb + 1 and used[j] == 0:
			pb = arr[j]
			used[j] = 1
	print(pa + pb + 2)


from collections import Counter

def func(A):
	m = max(A)
	A = Counter(A)
	f = max(A) + 1
	flag = False
	for i in range(m + 1):
		if i in A:
			A[i] -= 1
			if A[i] == 0:
				del A[i]
		else:
			flag = True
			f = i
			break
	if not A:
		return f
	s = max(A) + 1
	flag = False
	for i in range(m + 1):
		if i in A:
			A[i] -= 1
			if A[i] == 0:
				del A[i]
		else:
			flag = True
			s = i
			break
	if flag == True:
		return f + s
	else:
		return f + s
t = int(input())
for i in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	print(func(A))


a = int(input())
for i in range(a):
	b = int(input())
	c = list(map(int, input().split()))
	d = [0] * 101
	for j in range(b):
		d[c[j]] += 1
	e = 2
	f = 0
	for j in range(101):
		if not e:
			break
		elif e == 2:
			if d[j] >= 2:
				f += 2
			elif d[j] == 1:
				e = 1
				f += 1
			else:
				e = 0
		elif d[j]:
			f += 1
		else:
			e = 0
	print(f)


def mex(v):
	if not v:
		return 0
	if v[0] != 0:
		return 0
	for k in range(len(v) - 1):
		if abs(v[k] - v[k + 1]) > 1:
			return int(v[k] + 1)
	return int(v[len(v) - 1] + 1)
t = int(input())
for i in range(t):
	n = int(input())
	x = list(map(int, input().split(' ', n)))
	x.sort()
	a = []
	b = []
	for j in x:
		if a.count(j) > 0:
			b.append(j)
		else:
			a.append(j)
	print(int(mex(a) + mex(b)))


def ques2(n, a):
	c1 = c2 = 0
	if 0 not in a:
		return 0
	a.sort()
	d = {}
	for i in range(101):
		d[i] = 0
	for i in a:
		d[i] += 1
	for i in d:
		if d[i] < 1:
			c1 = i
			break
	for i in d:
		if d[i] <= 1:
			c2 = i
			break
	if c1 + c2 > 0:
		return c1 + c2
	else:
		return 100
t = int(input())
for i in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	ans = ques2(n, a)
	print(ans)


import sys
input = sys.stdin.readline
t = int(input())
for t1 in range(t):
	n = int(input())
	l = list(map(int, input().split(' ')))
	l.sort()
	d = {}
	for i in range(n):
		d[l[i]] = d.get(l[i], 0) + 1
	c = 0
	ans = 0
	f = 0
	while True:
		if d.get(c, 0) > 1:
			c += 1
		elif d.get(c, 0) == 1:
			if f == 0:
				ans += c
				f = 1
			c += 1
		else:
			ans += c
			if f == 0:
				ans += c
			break
	print(ans)


t = int(input())
while t > 0:
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in range(n):
		if l[i] in d:
			d[l[i]] += 1
		else:
			d[l[i]] = 1
	k = max(l)
	ans = 0
	for i in range(k + 2):
		if i not in d:
			ans += i
			break
		else:
			d[i] -= 1
	for i in range(k + 2):
		if i not in d:
			ans += i
			break
		elif d[i] == 0:
			ans += i
			break
	print(ans)
	t -= 1


for j in range(int(input())):
	n = int(input())
	a = [int(b) for b in input().split()]
	x = set()
	y = set()
	for i in range(n):
		if a[i] in x:
			y.add(a[i])
		else:
			x.add(a[i])
	x = sorted(x)
	y = sorted(y)
	ans = 0
	k = 0
	for i in x:
		if k != i:
			break
		k += 1
	ans += k
	k = 0
	for i in y:
		if k != i:
			break
		k += 1
	ans += k
	print(ans)


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	d = defaultdict(int)
	f = 0
	s = set()
	for i in l:
		s.add(i)
		d[i] += 1
		if d[i] > 1:
			f = 1
	ans = 0
	if f == 0:
		for i in range(max(l) + 2):
			if i not in s:
				ans = i
				break
		print(ans)
	else:
		s1 = set()
		s2 = set()
		for i in d:
			if d[i] > 1:
				s1.add(i)
				s2.add(i)
			else:
				s1.add(i)
		(m1, m2) = (0, 0)
		for i in range(max(s1) + 2):
			if i not in s1:
				m1 = i
				break
		for i in range(max(s2) + 2):
			if i not in s2:
				m2 = i
				break
		print(m1 + m2)


test = int(input())
for q in range(test):
	n = int(input())
	x = list(map(int, input().split()))
	f = {}
	for i in range(n):
		if x[i] in f:
			f[x[i]] += 1
		else:
			f[x[i]] = 1
	for i in range(max(x) + 2):
		if i not in f:
			a = i
			break
		f[i] -= 1
	for i in range(max(x) + 2):
		if i not in f or f[i] == 0:
			b = i
			break
		f[i] -= 1
	print(a + b)


t = int(input())
while t:
	n = int(input())
	arr = list(map(int, input().split()))
	occr = [0] * 101
	for e in arr:
		occr[e] += 1
	ans = 0
	minb = 102
	for i in range(0, 101):
		if occr[i] == 0:
			mina = i
			break
	for i in range(0, 101):
		if occr[i] == 1:
			minb = i
			break
	if mina < minb or minb == 102:
		minb = mina
	ans = mina + minb
	print(ans)
	t -= 1


from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	a = Counter(map(int, input().split()))
	ans = 0
	for i in range(101):
		if i in a and a[i] > 0:
			a[i] -= 1
			continue
		ans += i
		break
	for i in range(101):
		if i in a and a[i] > 0:
			a[i] -= 1
			continue
		ans += i
		break
	print(ans)


for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	lis.sort()
	a = [-1]
	b = [-1]
	for i in lis:
		if a[-1] != i:
			a.append(i)
		elif b[-1] != i:
			b.append(i)
	i1 = -1
	for j in a:
		if j != i1:
			break
		else:
			i1 += 1
	k1 = -1
	for j in b:
		if j != k1:
			break
		else:
			k1 += 1
	print(i1 + k1)


t = int(input())
for test_cases in range(t):
	n = int(input())
	l = sorted([int(i) for i in input().split(' ')])
	ls = [0] * n
	for i in range(n):
		if l[i] < n:
			ls[l[i]] += 1
	i = 0
	j = 0
	while i < n and ls[i] > 1:
		i += 1
	while j < n and ls[j] > 0:
		j += 1
	print(i + j)


n = int(input())
for i in range(n):
	l = int(input())
	a = [int(x) for x in input().split()]
	b = -1
	c = -1
	for j in range(101):
		if a.count(j) < 2:
			b = j
			break
	for j in range(101):
		if a.count(j) < 1:
			c = j
			break
	print(b + c)


def subset_mex():

	def find_minusone(ls: list):
		for i in range(len(ls)):
			if ls[i] == -1:
				return i
		return 0
	prob = int(input())
	for _ in range(prob):
		l = int(input())
		ts = list(map(int, input().split()))
		count1 = [-1] * 101
		count2 = [-1] * 101
		for i in ts:
			if count1[i] == -1:
				count1[i] = i
			elif count2[i] == -1:
				count2[i] = i
			else:
				continue
		mex1 = find_minusone(count1)
		mex2 = find_minusone(count2)
		print(mex1 + mex2)
subset_mex()


for _ in range(int(input())):
	n = int(input())
	arr = [int(X) for X in input().split()]
	temp = [0 for i in range(101)]
	for i in arr:
		temp[i] += 1
	first = -1
	second = -1
	for i in range(101):
		if temp[i] == 0:
			first = i
			break
	if first == -1:
		first = 101
	for i in range(101):
		if temp[i] <= 1:
			second = i
			break
	print(first + second)


tests = int(input())
while tests:
	tests -= 1
	n = input()
	l = [int(x) for x in input().split(' ')]
	freq = [0 for i in range(0, 101)]
	for i in l:
		freq[i] += 1
	answer = 0
	for i in range(101):
		if freq[i] == 0:
			answer = 2 * i
		elif freq[i] == 1:
			answer += i
			for j in range(i + 1, 101):
				if freq[j] in [0]:
					answer += j
					break
		else:
			continue
		break
	print(answer)


from collections import Counter

def tc():
	n = int(input())
	a = list(map(int, input().split()))
	c = Counter(a)
	ans = 0
	bad = 0
	for _ in range(2):
		for i in range(n + 1):
			if c[i]:
				c[i] -= 1
			else:
				ans += i
				bad += 1
				break
	print(ans)
T = int(input())
for _ in range(T):
	tc()


def mex(arr):
	if len(arr) == 0:
		return 0
	for i in range(arr[-1] + 2):
		if i in arr:
			pass
		else:
			return i
n = int(input())
for i in range(n):
	a = int(input())
	ar = sorted(list(map(int, input().split())))
	mn1 = []
	mn2 = []
	mn1.append(ar[0])
	for i in range(1, len(ar)):
		if ar[i] - mn1[-1] == 1:
			mn1.append(ar[i])
		else:
			mn2.append(ar[i])
	print(mex(mn1) + mex(mn2))


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	a1 = -1
	b1 = -1
	d1 = {}
	for i in a:
		if i in d1.keys():
			d1[i] += 1
		else:
			d1[i] = 1
	p = list(d1.keys())
	p.sort()
	for i in range(0, p[-1] + 1):
		if i not in d1.keys():
			if a1 == -1:
				a1 = i
			b1 = i
			break
		elif d1[i] == 1 and a1 == -1:
			a1 = i
	else:
		b1 = p[-1] + 1
		if a1 == -1:
			a1 = b1
	print(a1 + b1)
	t = t - 1


for _ in range(int(input())):
	n = int(input())
	l = []
	ano = []
	l = map(int, input().split())
	u = []
	l = sorted(l)
	for i in l:
		if i not in ano:
			ano.append(i)
		elif i not in u:
			u.append(i)
	flag = 0
	ans = 0
	ano = sorted(ano)
	u = sorted(u)
	if len(ano) != 0:
		for i in range(len(ano)):
			if i != ano[i]:
				flag = 1
				ans = i
				break
		if flag == 0:
			ans = i + 1
	else:
		ans = 0
	flag = 0
	if len(u) != 0:
		for i in range(len(u)):
			if i != u[i]:
				flag = 1
				ans += i
				break
		if flag == 0:
			ans += i + 1
	else:
		ans += 0
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	a = [s[0]]
	b = []
	if min(s) != 0:
		print(0)
	else:
		for i in range(1, n):
			if s[i] - a[-1] == 1:
				a.append(s[i])
			else:
				b.append(s[i])
		ans1 = max(a) + 1
		if len(b) == 0:
			ans2 = 0
		elif min(b) != 0:
			ans2 = 0
		elif len(b) == 1:
			ans2 = 1
		else:
			ans2 = 1
			for k in range(len(b) - 1):
				if b[k + 1] - b[k] != 1 and b[k + 1] - b[k] != 0:
					break
				ans2 = b[k + 1] + 1
		ans = ans1 + ans2
		print(ans)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	arr = Counter(map(int, input().split()))
	i = 0
	while arr[i] > 0:
		arr[i] -= 1
		i += 1
	out = i
	i = 0
	while arr[i] > 0:
		arr[i] -= 1
		i += 1
	out += i
	print(out)


loop = int(input())
for n in range(loop):
	l = int(input())
	s = input()
	lis = s.split(' ')
	for i in range(l):
		lis[i] = int(lis[i])
	c = sorted(lis)
	a = 0
	b = 0
	for k in range(l):
		if c[k] == a:
			a = a + 1
		elif c[k] == b:
			b = b + 1
	print(a + b)


from collections import Counter
for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	temp = set([i for i in range(0, 101)])
	cnt = Counter(a)
	ans = 0
	(p, q) = (0, 0)
	for x in temp:
		if x not in cnt:
			p = x
			break
	for x in temp:
		if cnt[x] <= 1:
			q = x
			break
	ans = p + q
	print(ans)


t = int(input())
for _ in range(t):
	x = 0
	k = 0
	n = int(input())
	count = [0] * 101
	for v in map(int, input().split()):
		count[v] += 1
	for i in range(101):
		if count[i] == 1:
			if k == 0:
				x += i
				k += 1
			elif count[i + 1] == 0:
				x += i + 1
				k += 1
		elif count[i] == 0:
			if k == 1:
				x += i
				k += 1
			else:
				x = 2 * i
				k += 2
		else:
			continue
		if k == 2:
			print(x)
			break


from collections import Counter as C
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	cnts = C(a)
	ans = 0
	b = 2
	for i in range(101):
		b = min(b, cnts[i])
		ans += b
	print(ans)


t = int(input())

def mes(l):
	for i in range(len(l) + 1):
		if i not in l:
			return i
	return len(l)
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	A = []
	B = []
	a.sort()
	hmm = 0
	for j in range(n - 1):
		if a[j] == hmm:
			A.append(a[j])
			hmm += 1
		else:
			B.append(a[j])
	if len(A) != 0:
		if A[-1] + 1 == a[-1]:
			A.append(a[-1])
		else:
			B.append(a[-1])
	else:
		A.append(a[-1])
	print(mes(A) + mes(B))


def least_min_int(set):
	if 0 in set:
		x = 0
		while x in set:
			x += 1
		return x
	else:
		return 0

def main():
	tc = int(input())
	res = []
	for i in range(tc):
		_ = input()
		a = map(int, input().split())
		(set1, set2) = (set(), set())
		for i in a:
			if i in set1:
				set2.add(i)
			else:
				set1.add(i)
		s1 = least_min_int(set1)
		s2 = least_min_int(set2)
		res.append(s1 + s2)
	print(*res, sep='\n')
main()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = 0
	sum = 0
	for i in a:
		if ans == i:
			ans += 1
		elif sum == i:
			sum += 1
	print(ans + sum)


t = int(input())
for tt in range(t):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	mex1 = mex2 = 0
	for i in a:
		if i == mex1:
			mex1 = i + 1
		elif i == mex2:
			mex2 = i + 1
	print(mex1 + mex2)


from collections import Counter
cases = int(input())
for t in range(cases):
	n = int(input())
	a = list(map(int, input().split()))
	a1 = Counter(a)
	a2 = []
	a3 = []
	for i in a1:
		a2.append(i)
		a1[i] -= 1
	for i in a1:
		if a1.get(i, 0):
			a3.append(i)
	a2 = set(a2)
	a3 = set(a3)
	la2 = len(a2)
	la3 = len(a3)
	m2 = set(range(la2 + 1))
	m3 = set(range(la3 + 1))
	print(min(m2 - a2) + min(m3 - a3))


t = int(input())
for _ in range(t):
	a = [0] * 101
	b = [0] * 101
	n = int(input())
	ls = list(map(int, input().split()))
	for i in ls:
		if a[i] == 1:
			b[i] = 1
		else:
			a[i] = 1
	ans = 0
	ind = 0
	flaga = 0
	flagb = 0
	while ind < 101 and (flaga != 1 or flagb != 1):
		if a[ind] == 0 and flaga != 1:
			flaga += 1
			ans += ind
		if b[ind] == 0 and flagb != 1:
			flagb += 1
			ans += ind
		ind += 1
	print(ans)


import sys
import math
from decimal import *

def I():
	return int(sys.stdin.readline())

def IL():
	return list(map(int, sys.stdin.readline().strip().split()))

def ILS():
	return list(map(str, sys.stdin.readline().strip().split()))

def solve():
	tt = I()
	for ii in range(tt):
		n = I()
		l = IL()
		last = max(l)
		d = {}
		for ll in l:
			if ll not in d:
				d[ll] = 1
			else:
				d[ll] += 1
		p = []
		a1 = None
		a2 = None
		ma = 0
		for x in range(0, last + 2):
			if x in d and d[x] > 0:
				d[x] -= 1
			else:
				a1 = x
				break
		for x in range(0, last + 2):
			if x in d and d[x] > 0:
				d[x] -= 1
			else:
				a2 = x
				break
		print(a1 + a2)
		pass
solve()


import sys, collections

def input():
	return sys.stdin.readline()[:-1]

def getInt():
	return int(input())

def getIntIter():
	return map(int, input().split())

def getIntList():
	return list(getIntIter())

def flush():
	sys.stdout.flush()
for _ in range(getInt()):
	n = getInt()
	nums = getIntList()
	c = collections.Counter(nums)
	out = 0
	curr = 0
	m = 2
	while curr in c.keys():
		out += min(c[curr], m)
		m = min(m, c[curr])
		curr += 1
	print(out)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	arr = Counter(map(int, input().split()))
	a = []
	b = []
	for i in arr:
		a.append(i)
		if arr[i] >= 2:
			b.append(i)
	last = a[-1] + 10
	a.append(last)
	a.sort()
	if len(b) != 0:
		last = b[-1] + 10
		b.append(last)
	b.sort()
	mex = []
	if len(a) != 0:
		for i in range(len(a) + 1):
			if i != a[i]:
				mex.append(i)
				break
	if len(b) != 0:
		for i in range(len(b) + 1):
			if i != b[i]:
				mex.append(i)
				break
	print(sum(mex))


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	dic = [0] * (100 + 1)
	for i in range(len(l)):
		dic[l[i]] += 1
	a = b = 0
	for i in range(len(dic)):
		if dic[i] == 0:
			a = i
			break
	for i in range(len(dic)):
		if dic[i] <= 1:
			b = i
			break
	print(a + b)


import sys
import math as mt
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in range(n):
		d[l[i]] = d.get(l[i], 0) + 1
	ans = 0
	for i in range(0, 102):
		if d.get(i, 0) == 0:
			ans = i
			break
		else:
			d[i] -= 1
	for i in range(0, 102):
		if d.get(i, 0) == 0:
			ans += i
			break
		else:
			d[i] -= 1
	print(ans)


from collections import Counter
for _ in range(int(input())):
	input()
	(set1, set2) = (set(), set())
	nam = [int(n) for n in input().split()]
	nam_c = Counter(nam)
	for i in range(0, max(nam) + 1):
		if nam_c[i] < 2:
			for j in range(i, max(nam) + 1):
				if j not in nam_c or nam_c[j] == 0:
					print(i + j)
					break
			else:
				print(j + 1 + i)
			break
	else:
		print(i * 2 + 2)


loop = int(input())
result = []
for i in range(0, loop):
	fl = 0
	sum = 0
	size = int(input())
	arr = list(map(int, input().split()))
	for j in range(0, size + 1):
		ct = 0
		for x in range(0, size):
			if j == arr[x]:
				ct = ct + 1
		if ct == 0 and fl == 0:
			sum = sum + 2 * j
			break
		elif ct == 1 and fl == 0:
			sum = sum + j
			fl = 1
		elif ct == 0 and fl == 1:
			sum = sum + j
			break
	result.append(sum)
print(*result, sep='\n')


for _ in range(int(input())):
	(n, l, a, b) = (int(input()), list(map(int, input().strip().split())), 0, 0)
	l.sort()
	for x in l:
		if x == a:
			a += 1
		elif x == b:
			b += 1
	print(a + b)


def solve():
	res = []
	for _ in range(int(input())):
		l = int(input())
		arr = list(map(lambda x: int(x), input().split(' ')))
		dl = [0 for _ in range(101)]
		for ar in arr:
			dl[ar] += 1
		r = 0
		cnt = 0
		i = 0
		while i < 101:
			if dl[i] == 0:
				r += i
				cnt += 1
				i -= 1
			elif dl[i] == 1:
				for j in range(i, 101):
					dl[j] += 1
				r += i
				cnt += 1
			if cnt >= 2:
				break
			i += 1
		res.append(r)
	return res
for s in solve():
	print(s)


MAXA = 100

def solve(n, a):
	cnt = [0] * (MAXA + 1)
	for v in a:
		cnt[v] += 1
	both = 0
	while both < len(cnt) and cnt[both] > 1:
		both += 1
	single = both
	while single < len(cnt) and cnt[single] > 0:
		single += 1
	return both + single
tests = int(input())
for test in range(tests):
	n = int(input())
	a = list(map(int, input().split()))
	print(solve(n, a))


from collections import defaultdict as dd
import sys
input = sys.stdin.readline
t = int(input())
while t:
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	ans = 0
	d = dd(int)
	for i in range(n):
		d[l[i]] += 1
	for i in range(102):
		if d[i] == 1 or d[i] == 0:
			ans = i
			break
	for i in range(102):
		if not d[i]:
			ans += i
			break
	print(ans)
	t -= 1


import sys
input = sys.stdin.readline
read = lambda : map(int, input().split())
read_float = lambda : map(float, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(councils, a, k):
	summ = 0
	for x in a:
		summ += min(x, councils)
	return summ // councils >= k
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math
import bisect as bis
import random
import sys

def solve():
	n = int(input())
	a = list(read())
	a.sort()
	if a[0] != 0:
		print(0)
		return
	first = []
	second = []
	mp = {}
	for x in a:
		if mp.get(x) == None:
			first.append(x)
			mp[x] = 1
		elif mp.get(x) != None:
			second.append(x)
	second = list(set(second))
	ans = 0
	i = 0
	for x in first:
		if x == i:
			i += 1
		else:
			break
	ans += i
	i = 0
	if len(second) == 0:
		print(ans)
		return
	for x in second:
		if x == i:
			i += 1
		else:
			break
	ans += i
	print(ans)
for _ in range(int(input())):
	solve()


from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	ali = list(map(int, input().split()))
	c = Counter()
	ans = 0
	for i in range(n):
		c[ali[i]] += 1
	for i in range(101):
		if c[i] == 0:
			ans += i
			break
	for i in range(101):
		if c[i] <= 1:
			ans += i
			break
	print(ans)


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().strip().split()))
	i = 0
	arr.sort()
	while True:
		if i in arr:
			arr.remove(i)
			i += 1
		else:
			break
	a = i
	i = 0
	while True:
		if i in arr:
			arr.remove(i)
			i += 1
		else:
			break
	b = i
	print(a + b)


def solve():
	n = int(input())
	s = input().split(' ')
	s = list(map(int, s))
	lib = {}
	M = 0
	for i in s:
		M = max(M, i)
		if i in lib:
			lib[i] += 1
		else:
			lib[i] = 1
	A = []
	for i in range(M + 1):
		if i in lib:
			if lib[i] == 0:
				break
			else:
				A.append(i)
				lib[i] -= 1
		else:
			break
	B = []
	for i in range(M + 1):
		if i in lib:
			if lib[i] == 0:
				break
			else:
				B.append(i)
				lib[i] -= 1
		else:
			break
	m = 0
	n = 0
	if A:
		m = max(A) + 1
	if B:
		n = max(B) + 1
	print(m + n)
n = int(input())
for i in range(n):
	solve()


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	freq = [0] * (arr[-1] + 1)
	for i in range(n):
		freq[arr[i]] += 1
	ans = 0
	do = 2
	for i in range(arr[-1] + 1):
		if do == 0:
			break
		elif do == 2:
			if freq[i] >= 2:
				continue
			elif freq[i] == 1:
				ans += i
				do -= 1
			else:
				ans += (i - 1) * do
				do = 0
		elif freq[i] >= 1:
			continue
		else:
			ans += i
			do -= 1
	res = 0
	chain = 1
	for i in range(arr[-1] + 1):
		if freq[i] >= 1:
			res += 1
			if freq[i] > 1 and chain:
				res += 1
			else:
				chain = 0
		else:
			break
	print(max(ans, res))


for test in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	if l[0] != 0:
		print(0)
	else:
		mexa = 0
		j = 0
		setd = list(set(l))
		mexb = len(setd)
		setd.sort()
		for i in range(len(setd)):
			if i != setd[i]:
				mexb = i
				break
		d = {}
		for i in l:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
		for i in range(n):
			if i not in d or d[i] < 2:
				mexa = i
				break
		print(mexa + mexb)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def solve(arr, n):
	ans = 0
	res = [0 for i in range(101)]
	for i in range(n):
		res[arr[i]] += 1
	sec = None
	for i in range(101):
		if res[i] <= 1 and sec == None:
			sec = i
		if res[i] == 0:
			ans = i
			break
	return ans + sec
t = inp()
while t > 0:
	n = inp()
	arr = inlt()
	print(solve(arr, n))
	t -= 1


def meh(a):
	b = set(a)
	i = 0
	while i in b:
		i += 1
	return i
n = int(input())
for i in range(n):
	k = int(input())
	myList = list(map(int, input().split()))
	b = []
	myList.sort()
	a = [myList[0]]
	for j in range(1, k):
		if myList[j] != myList[j - 1]:
			a.append(myList[j])
		else:
			b.append(myList[j])
	print(meh(a) + meh(b))


t = int(input())
for q in range(0, t):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [0] * 101
	for i in range(0, n):
		b[a[i]] += 1
	count = 0
	for i in range(0, 101):
		if b[i] == 0:
			count = i
			break
	for i in range(0, 101):
		if b[i] <= 1:
			count += i
			break
	print(count)


import math
t = int(input())
ans = []

def solve(arr):
	sets = 2
	i = 0
	ans = 0
	while sets > 0:
		cnt = arr.count(i)
		if cnt == 0:
			return ans
		if cnt < sets:
			sets -= 1
		ans += sets
		i += 1
	return ans
for i in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	ans.append(solve(arr))
for test in ans:
	print(test)


import collections
T = int(input())
for t in range(T):
	N = int(input())
	arr = [int(i) for i in input().split(' ')]
	d = {}
	for i in range(len(arr)):
		if arr[i] in d:
			d[arr[i]] += 1
		else:
			d[arr[i]] = 1
	i = 0
	A = 0
	B = 0
	while i in d and d[i] >= 2:
		A = i + 1
		B = i + 1
		i += 1
	while i in d:
		A = i + 1
		i += 1
	print(A + B)


import os
from io import BytesIO, IOBase
import sys

def main():
	from collections import Counter
	for t in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		b = Counter(a)
		c = []
		d = []
		for i in range(max(a) + 1):
			if b[i] >= 2:
				c.append(i)
				d.append(i)
			elif b[i] == 1:
				c.append(i)
		ans = 0
		flag = 0
		for i in range(len(c)):
			if i != c[i]:
				ans += i
				flag = 1
				break
		if flag == 0:
			ans = c[-1] + 1
		flag = 0
		for i in range(len(d)):
			if i != d[i]:
				ans += i
				flag = 1
				break
		if flag == 0:
			if d != []:
				ans += d[-1] + 1
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from collections import defaultdict

def def_value():
	return 0
cases = input()
for _ in range(int(cases)):
	d = defaultdict(def_value)
	res = 0
	len = int(input())
	x_str = input().strip().split(' ')
	for x in x_str:
		if int(x) < 0:
			continue
		d[int(x)] += 1
	for _ in range(2):
		for x in range(101):
			if d[x] == 0:
				res += x
				break
			else:
				d[x] -= 1
	print(res)


t = int(input())
for _ in range(t):
	n = input()
	v = [int(x) for x in input().split()]
	ok = True
	cont1 = 0
	cont2 = 0
	for x in range(0, 1001):
		if v.count(x) >= 2 and ok:
			cont1 = x + 1
			cont2 = x + 1
			continue
		if v.count(x) >= 1:
			cont1 = x + 1
			ok = False
		else:
			break
	print(cont1 + cont2)


import sys
input = sys.stdin.readline

def print(val):
	sys.stdout.write(str(val) + '\n')

def prog():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		counts = [0] * 101
		for i in range(n):
			counts[a[i]] += 1
		best2 = 0
		best1 = 0
		stopped = False
		for i in range(101):
			if counts[i] == 0:
				break
			else:
				if counts[i] >= 1:
					best1 += 1
				if counts[i] == 1:
					stopped = True
				if counts[i] > 1 and (not stopped):
					best2 += 1
		print(best1 + best2)
prog()


for o in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	p = 0
	r = [0 for i in range(101)]
	for i in range(n):
		r[s[i]] = r[s[i]] + 1
	for i in range(101):
		if r[i] >= 1:
			r[i] = r[i] - 1
		else:
			p = p + i
			break
	for i in range(101):
		if r[i] >= 1:
			r[i] = r[i] - 1
		else:
			p = p + i
			break
	print(p)


def solve():
	n = int(input())
	arr = [int(i) for i in input().strip().split()]
	arr.sort()
	count = [0] * 101
	for i in arr:
		count[i] += 1
	res = 0
	chos = 0
	for i in range(0, 101):
		if count[i] == 0:
			if chos == 1:
				res += i
			else:
				res += 2 * i
			break
		elif count[i] == 1:
			if chos == 0:
				res += i
				chos = 1
	print(res)
t = 1
t = int(input())
for i in range(0, t):
	solve()


for j in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	i = 0
	s = 0
	while True:
		if i in l:
			l.remove(i)
			i += 1
		else:
			s += i
			break
	i = 0
	while True:
		if i in l:
			l.remove(i)
			i += 1
		else:
			s += i
			break
	print(s)


def answer(n, A):
	arr = [0] * 102
	for i in range(n):
		arr[A[i]] += 1
	s1 = set()
	s2 = set()
	ans = 0
	for i in range(102):
		if arr[i] == 0:
			ans = i
			break
	flag = 1
	for i in range(102):
		if arr[i] == 1:
			s1.add(i)
			flag = 0
		elif arr[i] > 1:
			s1.add(i)
			if flag:
				s2.add(i)
		else:
			break
	if s2 and s1:
		ans = max(ans, max(s2) + 1 + max(s1) + 1)
	if s1:
		ans = max(ans, max(s1) + 1)
	return ans
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	print(answer(n, l))


for q in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	j = 0
	res = 0
	for i in range(n):
		if a[i] == j:
			res = j + 1
			a[i] = -1
			j += 1
	j = 0
	r = 0
	for i in range(n):
		if a[i] == j:
			r = j + 1
			a[i] = -1
			j += 1
	print(res + r)


from collections import defaultdict, Counter
from math import ceil, floor, log2
alph = 'abcdefghijklmnopqrstuvwxyz'
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	c = Counter(a)
	el = sorted(list(set(a)))
	total = 0
	added = False
	prev = -1
	count = 0
	for x in el:
		if x - 2 >= prev:
			break
		else:
			count += 1
			if c[x] == 1 and (not added):
				total += count - 1
				added = True
		prev = x
	if added:
		total += count
	else:
		total += count * 2
	print(total)


t = int(input())
while t:
	n = int(input())
	arr = list(map(int, input().split()))
	freq = [0 for i in range(101)]
	for i in arr:
		freq[i] += 1
	b = c = -1
	for i in range(101):
		if freq[i] > 0:
			freq[i] -= 1
		else:
			b = i
			break
	for i in range(106):
		if freq[i] > 0:
			freq[i] -= 1
		else:
			c = i
			break
	print(b + c)
	t -= 1


for _ in range(int(input())):
	a = int(input())
	b = sorted(list(map(int, input().split())))
	x = 0
	y = 0
	for i in b:
		if x == i:
			x += 1
		elif y == i:
			y += 1
	print(x + y)


from collections import Counter
from itertools import count

def solve(xs):
	d = Counter(xs)
	for elem in count():
		if d[elem]:
			d[elem] -= 1
		else:
			m1 = elem
			break
	for elem in count():
		if d[elem]:
			d[elem] -= 1
		else:
			m2 = elem
			break
	return m1 + m2
t = int(input())
for _ in range(t):
	_ = input()
	xs = [int(x) for x in input().split()]
	print(solve(xs))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	f = []
	for i in range(101):
		f.append(0)
	for i in l:
		f[i] += 1
	f1 = -1
	f2 = 0
	for i in range(101):
		if f[i] == 0:
			if f1 == -1:
				f1 = i
			f2 = i
			break
		if f[i] == 1:
			if f1 == -1:
				f1 = i
	print(f2 + f1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	c = [0] * 101
	for i in range(n):
		c[a[i]] += 1
	b0 = 100000.0
	b1 = 100000.0
	for i in range(101):
		if c[i] == 0:
			b0 = min(b0, i)
		elif c[i] == 1:
			b1 = min(b1, i)
	if b0 == 100000.0:
		print(100)
		continue
	elif b1 == 100000.0:
		print(2 * b0)
		continue
	if b0 < b1:
		print(2 * b0)
	else:
		for i in range(101):
			if i != b1 and c[i] == 0:
				print(b1 + i)
				break


def solve(arr, n):
	hashmap = [0 for i in range(101)]
	for x in arr:
		hashmap[x] += 1
	a = -1
	b = -1
	for i in range(101):
		if hashmap[i] < 2:
			if hashmap[i] == 0:
				a = i
				break
			else:
				hashmap[i] -= 1
	if a == -1:
		a = 101
	for j in range(101):
		if hashmap[j] < 2:
			b = j
			break
	if b == -1:
		b = 101
	return a + b
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	print(solve(arr, n))


n = int(input())
for i in range(n):
	t = int(input())
	x = [int(i) for i in input().split(' ')]
	(y, z) = ([], [])
	x.sort()
	for j in range(len(x)):
		if x[j] not in y:
			y.append(x[j])
		else:
			z.append(x[j])
	ans = 0
	if y:
		for i in range(y[-1] + 1):
			if i in y:
				pass
			else:
				ans += i
				break
		if i == y[-1]:
			ans += y[-1] + 1
	if z:
		for i in range(z[-1] + 1):
			if i in z:
				pass
			else:
				ans += i
				break
		if i == z[-1]:
			ans += z[-1] + 1
	print(ans)


def subsetmex(a):
	j = 0
	k = 0
	x = max(a)
	for i in range(x + 1):
		if i in a:
			j = i + 1
			a.remove(i)
		else:
			j = i
			break
	for i in range(len(a)):
		if i in a:
			k = i + 1
			continue
		else:
			k = i
			break
	return j + k
T = int(input())
for _ in range(T):
	a = int(input())
	b = list(map(int, input().split()))
	print(subsetmex(b))


t = int(input())
for t1 in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	a.sort()
	s = 0
	j = 0
	f = []
	f1 = 0
	for i in range(n):
		f.append(0)
	for i in range(n):
		if a[i] == j:
			j += 1
			f[i] = 1
		elif a[i] > j:
			s += j
			f1 = 1
			break
	if f1 == 0:
		s += j
	j = 0
	f1 = 0
	for i in range(n):
		if f[i] == 0 and a[i] == j:
			j += 1
		elif a[i] > j:
			s += j
			f1 = 1
			break
	if f1 == 0:
		s += j
	print(s)


from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	A = set(a)
	d = Counter(a)
	for i in A:
		d[i] -= 1
	B = set()
	for i in d:
		if d[i] > 0:
			B.add(i)
	temp = set()
	mx = max(a)
	for i in range(mx + 2):
		temp.add(i)
	print(min(temp - A) + min(temp - B))


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	for i in a:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	s1 = list(set(a))
	s1 = sorted(s1)
	s2 = []
	for i in d:
		if d[i] > 1:
			s2.append(i)
	s2 = list(set(s2))
	s2 = sorted(s2)
	i = 0
	j = 0
	ans = 0
	while i < len(s1):
		if s1[i] == i:
			i += 1
		else:
			ans = i
			break
	if i == len(s1):
		ans = i
	while j < len(s2):
		if s2[j] == j:
			j += 1
		else:
			ans += j
			break
	if j == len(s2):
		ans += j
	print(ans)


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	alst = list(map(int, input().split()))
	lst = [0 for _ in range(101)]
	for a in alst:
		lst[a] += 1
	ans = 0
	flg = False
	for (i, num) in enumerate(lst):
		if num == 0:
			if not flg:
				ans = i * 2
			else:
				ans += i
			break
		elif num == 1 and (not flg):
			ans += i
			flg = True
	print(ans)
for _ in range(int(input())):
	main()


from sys import stdin, stdout

def gmi():
	return map(int, stdin.readline().strip().split())

def gms():
	return map(str, stdin.readline().strip().split())

def gari():
	return list(map(int, stdin.readline().strip().split()))

def gars():
	return list(map(int, stdin.readline().strip().split()))

def gs():
	return stdin.readline().strip()

def gls():
	return list(stdin.readline())

def gi():
	return int(stdin.readline())

def mex(ar):
	if ar:
		for i in range(max(ar) + 2):
			if i not in ar:
				return i
	else:
		return 0
t = gi()
while t:
	t -= 1
	n = gi()
	ar = gari()
	(s1, s2) = ([], [])
	for i in sorted(ar):
		s1.append(i)
		s2.append(i)
		m1 = mex(s1)
		m2 = mex(s2)
		if m1 < m2:
			s1.pop()
		elif m1 > m2:
			s2.pop()
		elif len(s1) < len(s2):
			s2.pop()
		else:
			s1.pop()
	print(mex(s1) + mex(s2))


for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	has = [0] * 1000
	for i in lis:
		has[i] += 1
	fi = se = -1
	for i in range(200):
		if has[i] == 0:
			if fi == -1 and se == -1:
				fi = i
				se = i
				break
			elif fi != -1:
				se = i
				break
		elif has[i] == 1:
			if fi == -1:
				fi = i
	print(fi + se)


t = int(input())
for i in range(t):
	n = int(input())
	k = list(map(int, input().split()))
	(m1, m2) = (0, 0)
	for i in range(101):
		if k.count(i) < 2:
			m1 = i
			break
	for i in range(m1, 101):
		if k.count(i) < 1:
			m2 = i
			break
	print(m1 + m2)


for t in range(int(input())):
	n = int(input())
	arr1 = list(map(int, input().split()))
	arr2 = []
	mexa = 0
	mexb = 0
	for i in range(101):
		arr2.append(arr1.count(i))
	if 0 in arr2:
		mexa = arr2.index(0)
	for i in range(101):
		if arr2[i] == 0 or arr2[i] == 1:
			mexb = i
			break
	print(mexa + mexb)


from collections import Counter

def solver(arr):
	if len(arr) == 0:
		return 0
	set_arr = list(set(arr))
	set_arr.sort()
	if set_arr[0] != 0:
		return 0
	val = 0
	seq = []
	for (idx, item) in enumerate(set_arr):
		if idx == item:
			val += 1
			seq.append(idx)
		else:
			break
	counted = dict(Counter(arr))
	for i in seq:
		val += min(counted[i] - 1, 1)
		if counted[i] - 1 == 0:
			break
	return val
N = int(input())
for _ in range(N):
	n = int(input())
	arr = list(map(lambda x: int(x), input().split(' ')))
	print(solver(arr))


def don(arr):
	try:
		a = []
		b = []
		mex = []
		for value in arr:
			if value not in a:
				a.append(value)
			else:
				b.append(value)
		if a != []:
			max_a = max(a)
			for i in range(max_a + 2):
				if i not in a:
					mex.append(i)
					break
		if b != []:
			max_b = max(b)
			for j in range(max_b + 2):
				if j not in b:
					mex.append(j)
					break
		sum = 0
		for values in mex:
			sum = sum + values
		return sum
	except:
		return 0
t = int(input())
solution = []
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	x = don(arr)
	solution.append(x)
for values in solution:
	print(values)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	l = [0] * 102
	arr = list(map(int, input().split()))
	x = []
	for i in arr:
		l[i] += 1
	req = 2
	for i in range(102):
		while req > l[i]:
			req -= 1
			x += [i]
	print(sum(x))


t = int(input())
while t:
	t += -1
	vis = [0] * 102
	n = int(input())
	l = list(map(int, input().split()))
	for i in l:
		vis[i] -= -1
	t1 = 0
	for i in range(102):
		if vis[i] <= 1:
			t1 = i
			break
	t2 = 0
	for i in range(t1, 102):
		if vis[i] == 0:
			t2 = i
			break
	print(t1 + t2)


def mex(l):
	l = sorted(l)
	A = []
	B = []
	for var in l:
		if A:
			if var == A[-1]:
				B.append(var)
			else:
				A.append(var)
		else:
			A.append(var)
	return (A, B)

def min_mex(x):
	if not x:
		return 0
	for i in range(0, max(x)):
		if i not in x:
			return i
	return max(x) + 1
t = int(input())
for i in range(t):
	n = int(input())
	li = [int(s) for s in input().split()]
	(a, b) = mex(li)
	print(min_mex(a) + min_mex(b))


t = int(input())
for _ in range(t):
	n = int(input())
	li = list(map(int, input().split()))
	a = []
	b = []
	temp = []
	for i in li:
		if i not in a:
			a.append(i)
		else:
			b.append(i)
	a.sort()
	if b != temp:
		b.sort()
	x = -1
	y = -1
	A = [i for i in range(len(a))]
	B = [i for i in range(len(b))]
	for i in range(len(a)):
		if a[i] != A[i]:
			x = A[i]
			break
	a = list(set(a))
	a.sort()
	if x == -1:
		if a[0] == 0:
			x = len(a)
		else:
			x = 0
	b = list(set(b))
	b.sort()
	for i in range(len(b)):
		if b[i] != B[i]:
			y = B[i]
			break
	if y == -1:
		if len(b) != 0:
			if b[0] == 0:
				y = len(b)
			else:
				y = 0
		else:
			y = 0
	print(x + y)


t = int(input())
while t:
	t = t - 1
	n = int(input())
	a = list(map(int, input().split()))
	x = [0 for i in range(101)]
	cnt = 0
	out = 0
	for i in a:
		x[i] += 1
	flag = 0
	for i in range(101):
		if x[i] >= 1:
			x[i] -= 1
			continue
		if x[i] == 0:
			out += i
			flag = 1
		if flag:
			break
	flag = 0
	for i in range(101):
		if x[i] >= 1:
			x[i] -= 1
			continue
		if x[i] == 0:
			out += i
			flag = 1
		if flag:
			break
	print(out)


import sys

def input():
	return sys.stdin.readline().rstrip()
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	values = [0] * 101
	for v in arr:
		values[v] += 1
	target = 1
	ans = 0
	for index in range(0, 101):
		if values[index] == target:
			ans += index
			target -= 1
			if target < 0:
				break
		if values[index] == target - 1:
			ans = 2 * index
			target = -1
			break
	if target == -1:
		print(ans)
	elif target == 0:
		print(ans + 101)
	else:
		print(2 * 101)


for s in [*open(0)][2::2]:
	a = [0] * 101
	for x in s.split():
		a[int(x)] += 1
	i = a.index(0)
	a[i] = 1
	print(i + a.index(1))


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 998244353
EPS = 1e-06

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	n = Int()
	a = sorted(array())
	C = Counter(a)
	found = False
	ans = 0
	for i in range(105):
		if C[i] < 2 and (not found):
			found = True
			ans += i
		if found and C[i] == 0:
			ans += i
			break
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(s1, s2) = (set(), set())
	for i in a:
		if a.count(i) > 1:
			s1.add(i)
			s2.add(i)
		else:
			s1.add(i)
	ans = 0
	for i in range(n + 1):
		if i not in s1:
			ans += i
			break
	for i in range(n + 1):
		if i not in s2:
			ans += i
			break
	print(ans)


num_cases = int(input())
for i in range(num_cases):
	case_len = input()
	case_str = input()
	integers = list(map(int, case_str.split(' ')))
	max_integer = max(integers)
	max_sum = 0
	max_sum_count = 0
	for j in range(max_integer + 2):
		j_count = integers.count(j)
		if j_count == 0:
			if max_sum_count == 0:
				max_sum += j
				max_sum_count += 1
			max_sum += j
			max_sum_count += 1
		if j_count == 1 and max_sum_count == 0:
			max_sum += j
			max_sum_count += 1
		if max_sum_count > 1:
			break
	print(max_sum)


import sys
from collections import defaultdict
name = sys.stdin.read()
jobGrid = []
isJob = True
row = []
grid = name.split('\n')
grid = grid[:-1]
number_of_cases = int(grid[0])
for i in range(number_of_cases):
	l = list(map(int, grid[i * 2 + 2].split()))
	sum1 = 0
	sum2 = 0
	l.sort()
	newvalue = 0
	if l[0] != 0:
		print(0)
		continue
	for (j, k) in enumerate(l):
		if k - newvalue > 1:
			sum1 = newvalue + 1
			break
		else:
			newvalue = k
			sum1 = newvalue + 1
	if len(l) > 1 and l[1] != 0:
		print(sum1)
		continue
	newvalue = 0
	twice = 0
	for k in range(0, len(l), 1):
		if l[k] - newvalue > 1:
			sum2 = newvalue + 1
			break
		elif twice == 1 and sum2 != l[k] + 1:
			newvalue = l[k]
			sum2 = newvalue + 1
			twice = 0
		elif twice == 0 and sum2 != l[k] + 1:
			twice = 1
	print(sum1 + sum2)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list([int(x) for x in input().split()])
	nui = max(l)
	l1 = []
	l2 = []
	ll = list()
	for i in range(nui + 1):
		c = 0
		for j in l:
			if i == j:
				c += 1
		if c == 1:
			l1.append(i)
		if c >= 2:
			l1.append(i)
			l2.append(i)
			ll.append(i * i)
	m1 = max(l1)
	kkk = -1
	s = 0
	for i in range(m1 + 1):
		if i not in l1:
			kkk = i
			break
	s2 = -1
	if len(l2) > 0:
		m2 = max(l2)
		for i in range(m2 + 1):
			if i not in l2:
				s2 = i
				break
	else:
		s2 = 0
	if kkk == -1:
		kkk = m1 + 1
	if s2 == -1:
		s2 = m2 + 1
	s = kkk + s2
	v = 98
	print(s + 98 - v)


t = int(input())

def mex1(arr):
	i = 0
	while 1:
		if i not in arr:
			return i
		else:
			i += 1

def mex2(arr):
	i = 0
	while 1:
		if arr.count(i) < 2:
			return i
		else:
			i += 1
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	if 0 not in arr:
		print(0)
	elif arr.count(0) == 1:
		print(mex1(arr))
	else:
		print(mex1(arr) + mex2(arr))


t = int(input())
for i in range(t):
	n = int(input())
	arr = [0] * 101
	item = list(map(int, input().split()))
	for j in item:
		arr[j] += 1
	if arr[0] == 0:
		print(0)
	elif arr[0] == 1:
		j = 0
		while j <= 100:
			if arr[j] == 0:
				print(j)
				break
			elif j == 100:
				print(101)
				break
			j += 1
	else:
		one = 0
		j = 1
		while j <= 100:
			if arr[j] == 0:
				if one != 0:
					print(one + j)
				else:
					print(2 * j)
				break
			elif arr[j] == 1:
				if one == 0:
					one = j
			j += 1


for test in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split(' ')]
	freq = [0 for i in range(0, 101)]
	for i in l:
		freq[i] += 1
	ans = 0
	for i in range(101):
		if freq[i] == 0:
			ans = 2 * i
			break
		elif freq[i] == 1:
			ans += i
			for j in range(i + 1, 101):
				if freq[j] in [0]:
					ans += j
					break
			break
	print(ans)


t = int(input())
while t:
	l = [0] * 101
	n = int(input())
	li = list(map(int, input().split()))
	for i in range(n):
		l[li[i]] += 1
	a = 0
	b = 0
	for i in range(101):
		if l[i] == 0:
			a = i
			break
	for i in range(101):
		if l[i] < 2:
			b = i
			break
	print(a + b)
	t -= 1


def Achake(a):
	n = 0
	while True:
		if n not in a:
			return n
		n = n + 1

def Bchake(b):
	n = 0
	while True:
		if n not in b:
			return n
		n = n + 1
for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	a = []
	b = []
	for i in range(n):
		if l[i] not in a:
			a.append(l[i])
		else:
			b.append(l[i])
	print(Achake(a) + Bchake(b))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	(a, b) = (0, 0)
	for i in range(101):
		if i not in l:
			a = i
			break
	for i in range(101):
		if l.count(i) <= 1:
			b = i
			break
	print(a + b)


import math
from collections import deque
from sys import stdin, stdout
from string import ascii_letters
import sys
letters = ascii_letters
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	vals = dict()
	for i in map(int, input().split()):
		if i not in vals:
			vals[i] = 0
		vals[i] += 1
	was = False
	res = 0
	for g in range(0, 1000):
		if not was:
			if g in vals and vals[g] >= 2:
				continue
			res += g
			was = True
			if g not in vals:
				res += g
				break
		elif g not in vals:
			res += g
			break
	print(res)


testcases = int(input())
for _ in range(testcases):
	cnt = [0 for i in range(0, 101)]
	n = int(input())
	l = list(map(int, input().split()))
	for i in l:
		cnt[i] += 1
	(a_mex, i) = (0, 0)
	while True:
		if cnt[i] == 0:
			a_mex = i
			break
		else:
			cnt[i] -= 1
		i += 1
	(b_mex, i) = (0, 0)
	while True:
		if cnt[i] == 0:
			b_mex = i
			break
		i += 1
	print(a_mex + b_mex)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	(l1, l2) = ({}, {})
	for i in l:
		if i not in l1:
			l1[i] = 1
		else:
			l2[i] = 1
	l1 = sorted(list(l1.keys()))
	l2 = sorted(list(l2.keys()))
	(m1, m2) = (None, None)
	for i in range(len(l1)):
		if i != l1[i]:
			m1 = i
			break
	if m1 == None:
		m1 = len(l1)
	for i in range(len(l2)):
		if i != l2[i]:
			m2 = i
			break
	if m2 == None:
		m2 = len(l2)
	print(m1 + m2)


for i in range(int(input())):
	n = int(input())
	ar = [int(i) for i in input().split()]
	ar.sort()
	(a, b) = (0, 0)
	for i in ar:
		if a == i:
			a += 1
		elif b == i:
			b += 1
	print(a + b)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	at = list(a)
	at.sort()
	ma = -1
	mb = -1
	for i in range(101):
		try:
			at.remove(i)
			ma = i
		except:
			break
	for i in range(101):
		try:
			at.remove(i)
			mb = i
		except:
			break
	print(ma + mb + 2)


num_cases = int(input())
for case in range(num_cases):
	num_ints = int(input())
	ints = input().split()
	ints = [int(n) for n in ints]
	ints = sorted(ints)
	if ints[0] > 0:
		ans = 0
	else:
		a_found = False
		a = -1
		for i in range(num_ints * 2):
			count = ints.count(i)
			if count == 0 and (not a_found):
				ans = 2 * i
				break
			if count == 0 and a_found:
				ans = a + i
				break
			if count == 1:
				if not a_found:
					a_found = True
					a = i
	print(ans)


for _ in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	d = {}
	for i in l:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	k = 0
	for i in range(101):
		if i in d:
			d[i] -= 1
		else:
			a = i
			break
	for i in range(101):
		if i in d:
			if d[i] == 0:
				b = i
				break
		else:
			b = i
			break
	print(a + b)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	a = [0] * 102
	for i in l:
		a[i] += 1
	ma1 = -1
	ma2 = -1
	for i in range(101):
		if a[i] >= 2:
			if ma2 == i - 1:
				ma2 = i
				ma1 = i
			else:
				ma1 = i
		elif a[i] == 1:
			ma1 = i
		else:
			break
	print(ma1 + ma2 + 2)


for _ in range(int(input())):
	(n, lst, a, b) = (int(input()), sorted(list(map(int, input().split()))), 0, 0)
	for i in lst:
		if a == i:
			a += 1
		elif b == i:
			b += 1
	print(a + b)


def Solve(Set, n):
	if 0 not in Set:
		return 0
	(A, B) = ([], [])
	dic = {}
	Mex_s = 0
	for i in range(101):
		if i not in Set:
			Mex_s = i
			break
	for num in Set:
		try:
			dic[num] += 1
		except:
			dic[num] = 1
	for num in dic:
		A.append(num)
		dic[num] -= 1
		if dic[num] > 0:
			B.append(num)
	(Mex_a, Mex_b) = (0, 0)
	for i in range(101):
		if i not in A:
			Mex_a = i
			break
	for i in range(101):
		if i not in B:
			Mex_b = i
			break
	return max(Mex_s, Mex_b + Mex_a)
for _ in range(int(input())):
	n = int(input())
	S = list(map(int, input().split()))
	S = sorted(S)
	print(Solve(S, n))


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	ls = [int(x) for x in input().split()]
	se = set()
	for i in range(102):
		if i in ls:
			se.add(i)
			continue
		else:
			cnt = i
			break
	c = Counter(ls)
	for j in range(102):
		if j in se:
			if c[j] > 1:
				continue
			else:
				cnt2 = j
				break
		else:
			cnt2 = j
			break
	print(cnt + cnt2)


def mex(crr):
	crr = list(set(crr))
	if len(crr) == 0:
		return 0
	else:
		ans = len(crr)
		for i in range(0, len(crr)):
			if crr[i] == i:
				pass
			else:
				ans = i
				break
		return ans
from collections import deque, defaultdict, Counter, OrderedDict
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	(a, b) = ([], [])
	for i in arr:
		if i not in a:
			a.append(i)
		else:
			b.append(i)
	a.sort()
	b.sort()
	x = mex(a)
	y = mex(b)
	print(x + y)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = 0
	flag = False
	for i in range(n):
		if i in a:
			a.remove(i)
		else:
			ans += i
			flag = True
			break
	if not flag:
		ans += n
	flag = False
	for i in range(n):
		if i in a:
			a.remove(i)
		else:
			ans += i
			flag = True
			break
	if not flag:
		ans += n
	print(ans)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	dic = {}
	for i in arr:
		try:
			dic[i] += 1
		except:
			dic[i] = 1
	a = []
	b = []
	for i in dic:
		a += [i] * 1
		b += [i] * (dic[i] - 1)
	a = list(set(a))
	b = list(set(b))
	ans = 0
	c = 0
	for i in a:
		if i == c:
			c += 1
		else:
			break
	ans += c
	c = 0
	for i in b:
		if i == c:
			c += 1
		else:
			break
	print(ans + c)


for i in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	l = [0, 0]
	for i in a:
		if i == l[0]:
			l[0] += 1
		elif i == l[1]:
			l[1] += 1
	print(sum(l))


t = int(input())
for _ in range(0, t):
	n = int(input())
	l = list(map(int, input().split()))
	if 0 not in l:
		print(0)
	elif l.count(0) == 1:
		l = [*set(l)]
		l = sorted(l)
		for i in range(0, max(l) + 2):
			if i not in l:
				print(i)
				break
	else:
		ans = 0
		for w in range(0, 2):
			a = [*set(l)]
			a = sorted(a)
			for i in range(0, max(l) + 2):
				if i not in l:
					ans += i
					break
				else:
					l.remove(i)
		print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	s = list(set(l))
	f = 0
	res = 0
	for i in range(0, 101):
		cnt = l.count(i)
		if cnt == 0 and f == 0:
			res = 2 * i
			break
		elif cnt <= 1:
			if f == 0:
				res += i
				f = 1
			elif f == 1 and cnt == 0:
				res += i
				break
	print(res)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = {}
	for i in a:
		b[i] = b.get(i, 0) + 1
	c = 101
	d = 101
	for i in range(101):
		if b.get(i, 0) < 2:
			c = i
			break
	for i in range(101):
		if b.get(i, 0) == 0:
			d = i
			break
	print(c + d)


from collections import defaultdict
t = int(input())
ans = []
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	c = defaultdict(int)
	for x in a:
		if c[x] < 2:
			c[x] += 1
	ret = 0
	lf = True
	for i in range(n + 1):
		if i not in c:
			if lf:
				ret = i << 1
			else:
				ret += i
			break
		elif c[i] == 1:
			if lf:
				lf = False
				ret = i
	ans.append(str(ret))
print('\n'.join(ans))


for T in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	count = [0] * 101
	for i in a:
		count[i] += 1
	mex = -1
	for i in range(101):
		if count[i] == 0:
			mex = i
			break
	if mex == -1:
		mex = 101
	check = -1
	for i in range(101):
		if count[i] == 1 or count[i] == 0:
			mex += i
			check = i
			break
	if check == -1:
		mex += 101
	print(mex)


import bisect
import collections
import copy
import fractions
import functools
import heapq
import math
import random
import sys

def _p(str):
	sys.stdout.write(str + '\n')

def _i():
	return sys.stdin.readline()
T = int(_i())
for t in range(T):
	N = int(_i())
	A = list(map(int, _i().split()))
	cnts = {}
	for a in A:
		if a not in cnts:
			cnts[a] = 0
		cnts[a] += 1
	(m1, m2) = (None, None)
	for n in range(N + 2):
		if n not in cnts:
			if m1 is None:
				m1 = n
			m2 = n
			break
		if cnts[n] == 1:
			if m1 is None:
				m1 = n
	_p(str(m1 + m2))
sys.stdout.flush()


def ans(n, a):
	(A, B) = (set(), set())
	(mA, mB) = (0, 0)
	m = {}
	for i in range(n):
		if a[i] not in m:
			m[a[i]] = 0
		m[a[i]] += 1
	canUpdateB = True
	for i in range(0, 101):
		if i not in m:
			break
		if m[i] >= 2:
			mA += 1
			if canUpdateB:
				mB += 1
		elif m[i] == 1:
			canUpdateB = False
			mA += 1
		else:
			break
	return mA + mB
t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split(' ')))
	out = ans(n, a)
	print(out)
	t -= 1


from collections import deque as dq
from collections import defaultdict as dd
from collections import Counter as ct
from functools import lru_cache as lc
from heapq import heappush as hpush, heappop as hpop, heapify as hfy
from bisect import bisect_left, bisect_right
import itertools as it
import math
import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	A = list(map(int, input().split()))
	C = ct(A)
	ret = 0
	for i in range(110):
		if C[i] < 2:
			ret += i
			break
	for i in range(110):
		if C[i] < 1:
			ret += i
			break
	print(ret)
t = int(input())
for i in range(t):
	solve()


def mex(a):
	m = 0
	while m in a:
		m += 1
	return m
cases = int(input())
for _ in range(cases):
	n = int(input())
	ints = input()
	arr = ints.split(' ')
	arr = [int(a) for a in arr]
	m_0 = mex(arr)
	a = []
	b = []
	for i in range(n):
		if arr.count(i) > 1:
			b.append(i)
			arr.remove(i)
	a = arr
	print(max(m_0, mex(a) + mex(b)))


def solve():
	n = int(input().strip())
	a = list(map(int, input().strip().split()))
	count = {i: 0 for i in range(102)}
	for i in a:
		count[i] += 1
	mexA = None
	mexB = None
	for i in range(101):
		if count[i] == 1:
			if mexA == None:
				mexA = i
		elif count[i] == 0:
			if mexA == None:
				mexA = i
			if mexB == None:
				mexB = i
			break
	print(mexA + mexB)
t = int(input().strip())
for _ in range(t):
	solve()


number_of_entries = int(input())
len_of_array = []
array = []
for i in range(number_of_entries):
	ithlen = int(input())
	itharray = list(map(int, input().split()))
	len_of_array.append(ithlen)
	array.append(itharray)

def calculate_mex(len_of_array, array):
	array.sort()
	mex = 0
	for i in range(len_of_array):
		if array[i] == mex:
			mex += 1
	return mex

def maximum_sum_of_mex_of_subsets(len_of_array, array):
	array.sort()
	sub_array1 = []
	sub_array2 = []
	for i in range(len_of_array - 1):
		if array[i] == array[i + 1]:
			array[i] = -1
			sub_array1.append(array[i + 1])
	for i in range(len_of_array):
		if array[i] != -1:
			sub_array2.append(array[i])
	mex1 = calculate_mex(len(sub_array1), sub_array1)
	mex2 = calculate_mex(len(sub_array2), sub_array2)
	return mex1 + mex2
for i in range(number_of_entries):
	ans = maximum_sum_of_mex_of_subsets(len_of_array[i], array[i])
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	values = sorted(list(map(int, input().split())), reverse=True)
	B = []
	firstMex = -1
	secondMex = -1
	for i in range(n + 1):
		if i == n or not values:
			firstMex = i
			break
		while values and values[-1] < i:
			B.append(values.pop())
		if values and i == values[-1]:
			values.pop()
		else:
			firstMex = i
			break
	B += values
	n = len(B)
	B.sort(reverse=True)
	for i in range(n + 1):
		if i == n or not B:
			secondMex = i
			break
		while B and B[-1] < i:
			B.pop()
		if B and i == B[-1]:
			B.pop()
		else:
			secondMex = i
			break
	print(firstMex + secondMex)


for _ in range(int(input())):
	n = int(input())
	t = list(map(int, input().split()))
	t.sort()
	l = []
	for i in range(n):
		l.append(i)
	a = []
	out = 0
	for i in range(n):
		if l[i] not in t:
			break
		a.append(i)
	if len(a) != 0:
		out += max(a) + 1
	for i in a:
		t.remove(i)
	b = t[:]
	f = 0
	for i in range(n):
		if l[i] not in b:
			f = 1
			out += l[i]
			break
	if f == 0:
		if len(b) != 0:
			out += max(b) + 1
	print(out)


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	d = {}
	ans = 0
	for x in a:
		if x not in d:
			d[x] = 0
		d[x] += 1
	for _ in range(2):
		i = 0
		while True:
			try:
				if d[i] == 0:
					int('d')
				d[i] -= 1
			except:
				ans += i
				break
			i += 1
	print(ans)
t = int(input())
for x in range(t):
	solve()


for _ in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	ch = 0
	low = []
	c = 0
	for i in range(110):
		if ch not in a:
			low.append(ch)
			c = c + 1
		if c == 2:
			break
		ch = ch + 1
	for i in a:
		chk = a.count(i)
		if chk == 1:
			low.append(i)
			break
	if len(low) > 2:
		low[2] = low[0] + low[2]
	low[1] = low[0] + low[1]
	low[0] = low[0] + low[0]
	print(min(low))


t = int(input())
for i in range(t):
	n = int(input())
	s = [int(v) for v in input().split()]
	s.sort()
	m1 = 0
	m2 = 0
	for v in s:
		if v == m1:
			m1 += 1
		elif v == m2:
			m2 += 1
		elif v > m1 and v > m2:
			break
	print(m1 + m2)


for _ in range(int(input())):
	n = int(input())
	s = 0
	l = list(map(int, input().split()))
	for i in range(102):
		if i not in l:
			s = s + i
			break
	for i in range(102):
		if l.count(i) < 2:
			s = s + i
			break
	print(s)


test_cases = int(input())

def mex(arr):
	num = 0
	while True:
		if num not in arr:
			break
		num += 1
	return num

def non_repeat(arr):
	num = 0
	while True:
		if arr.count(num) < 2:
			break
		num += 1
	return num
for i in range(test_cases):
	arr_size = int(input())
	arr = list(map(int, input().split()))
	print(mex(arr) + non_repeat(arr))


from collections import Counter

def read_line():
	return list(map(int, input().split()))
T = int(input())
for _ in range(T):
	n = int(input())
	l = list(sorted(read_line()))
	l2 = Counter(l)
	m1 = 0
	ok = True
	m2 = 0
	for i in range(0, 101):
		if l2[i] >= 2 and ok:
			m1 += 1
			m2 += 1
		elif l2[i] >= 1:
			m1 += 1
			ok = False
		else:
			break
	print(m1 + m2)


import collections
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	idx = [0] * 101
	for i in range(n):
		idx[a[i]] += 1
	ans = 0
	t = 0
	for i in range(101):
		if idx[i] == 0 and t == 0:
			ans = 2 * i
			break
		elif idx[i] == 0 and t == 1:
			ans += i
			break
		elif idx[i] == 1 and t == 0:
			ans += i
			t += 1
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	for j in range(101):
		if j not in a:
			mex_a = j
			break
		if j in a:
			a.remove(j)
	for j in range(101):
		if j not in a:
			mex_b = j
			break
	print(mex_a + mex_b)


def ans(a, n):
	arr = [0] * 101
	for i in a:
		arr[i] += 1
	for i in range(len(arr)):
		if arr[i] == 0:
			t = i
			break
	for i in range(len(arr)):
		if arr[i] <= 1:
			u = i
			break
	return t + u
m = int(input())
for j in range(m):
	n = int(input())
	a = input().split()
	arr = []
	for i in a:
		arr.append(int(i))
	print(ans(arr, n))


for i in range(int(input())):
	n = int(input())
	mas = list(map(int, input().split()))
	otv = [0 for i in range(102)]
	for j in mas:
		otv[j] += 1
	kol = 2
	tum = 1
	ans = 0
	for j in range(0, 102):
		if kol == 0:
			print(ans)
			break
		if otv[j] == 0:
			if kol == 2:
				ans = 2 * j
				print(ans)
				break
			else:
				ans += j
				print(ans)
				break
		elif otv[j] == 1 and tum:
			if kol == 1:
				ans += j
				print(ans)
				break
			elif kol == 2:
				kol -= 1
				tum = 0
				ans += j


from collections import Counter
from collections import defaultdict
from collections import deque
import math
import heapq
import sys
import io, os
input = sys.stdin.readline
from bisect import *
rs = lambda : input().strip()
ri = lambda : int(input())
rl = lambda : list(map(int, input().strip().split()))
rls = lambda : list(map(str, input().split()))
t = int(input())
for _ in range(0, t):
	n = ri()
	a = rl()
	d = defaultdict(lambda : 0)
	x1 = []
	x2 = []
	ans1 = 0
	ans2 = 0
	for i in range(0, 101):
		if i not in a:
			ans1 = i
			break
		else:
			a.remove(i)
	for i in range(0, 101):
		if i not in a:
			ans2 = i
			break
	print(ans1 + ans2)


def getMex(arr):
	arr.sort()
	c = 0
	(l1, l2) = ([-1], [-1])
	for i in arr:
		if i == l1[-1]:
			l2.append(i)
		else:
			l1.append(i)
	i = 0
	while i in l1:
		i += 1
	c += i
	i = 0
	while i in l2:
		i += 1
	c += i
	return c
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	print(getMex(arr))


from sys import stdin, stdout

class SOLVE:

	def solve(self):
		R = stdin.readline
		W = stdout.write
		ans = []
		for i in range(int(R())):
			n = int(R())
			a = [int(x) for x in R().split()]
			a.sort()
			A = {}
			B = {}
			for j in range(n):
				if a[j] not in A:
					A[a[j]] = 1
				elif a[j] not in B:
					B[a[j]] = 1
			val = 0
			for j in range(102):
				if j not in A:
					val += j
					break
			for j in range(102):
				if j not in B:
					val += j
					break
			ans.append(str(val))
		W('\n'.join(ans))

def main():
	s = SOLVE()
	s.solve()
main()


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	res = 0
	b = [0] * 101
	for x in a:
		b[x] += 1
	for x in range(102):
		if b[x] == 0:
			res = x
			break
		else:
			b[x] -= 1
	for x in range(102):
		if b[x] == 0:
			res += x
			break
	print(res)


t = int(input())
while t != 0:
	n = int(input())
	a = list(map(int, input().split()))[:n]
	b = [i for i in range(n)]
	net = [0] * 101
	for i in range(n):
		net[a[i]] += 1
	for i in range(101):
		if net[i] == 0:
			x = i
			break
		else:
			net[i] -= 1
	for i in range(101):
		if net[i] == 0:
			y = i
			break
		else:
			net[i] -= 1
	print(x + y)
	t -= 1


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return [int(i) for i in input().split()]

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return (r, prime)

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	new_number = 0
	while number > 0:
		new_number += number % base
		number //= base
	return new_number

def cdiv(n, k):
	return n // k + (n % k != 0)

def ispal(s):
	for i in range(len(s) // 2 + 1):
		if s[i] != s[-i - 1]:
			return False
	return True

def main():
	for i in range(ii()):
		n = ii()
		arr = li()
		arr = sorted(arr)
		s1 = []
		s2 = []
		k = 0
		for ele in arr:
			if k == ele:
				s1.append(ele)
				k += 1
			else:
				s2.append(ele)
		m1 = 0
		m2 = 0
		for ele in s1:
			if ele == m1:
				m1 += 1
		for ele in s2:
			if ele == m2:
				m2 += 1
		print(m1 + m2)
main()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math
from collections import Counter, defaultdict, deque

def int1():
	return int(input())

def map1():
	return map(int, input().split())

def list1():
	return list(map(int, input().split()))
mod = pow(10, 9) + 7

def solve():
	n = int1()
	l1 = list1()
	k = Counter(l1)
	x1 = []
	x2 = []
	for i in k:
		if k[i] == 1:
			x1.append(i)
		else:
			x1.append(i)
			x2.append(i)
	x1.sort()
	x2.sort()
	sum1 = 0
	for i in range(len(x1)):
		if x1[i] != i:
			sum1 += i
			break
	else:
		sum1 += len(x1)
	for i in range(len(x2)):
		if x2[i] != i:
			sum1 += i
			break
	else:
		sum1 += len(x2)
	print(sum1)
for _ in range(int(input())):
	solve()


import sys
from sys import stdin, stdout
import math
import random
import heapq
from collections import Counter
from functools import lru_cache
try:
	for _ in range(int(input())):
		n = int(input())
		mp = {i: 0 for i in range(101)}
		arr = [int(i) for i in input().split()]
		for i in arr:
			mp[i] += 1
		ans = 0
		for i in range(101):
			if mp[i] == 0:
				ans += i
				break
		for i in range(101):
			if mp[i] < 2:
				ans += i
				break
		print(ans)
except EOFError as e:
	print(e)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	cc = Counter(l)
	(x, y) = (0, 0)
	for i in range(101):
		if cc[i] >= 2:
			continue
		else:
			x = i
			y = i
			break
	d = i
	for i in range(d, 101):
		if cc[i] >= 1:
			continue
		else:
			x = i
			break
	print(x + y)


t = int(input())
while t > 0:
	lst = []
	n = int(input())
	lst = list(map(int, input().split(' ')))
	lst.sort()
	curr = 0
	sum = 0
	while True:
		if curr not in lst:
			sum += curr
			break
		lst.remove(curr)
		curr += 1
	curr = 0
	while True:
		if curr not in lst:
			sum += curr
			break
		lst.remove(curr)
		curr += 1
	print(sum)
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	a = []
	b = []
	for i in range(101):
		a.append(-1)
		b.append(-1)
	for j in input().split():
		k = int(j)
		if a[k] > -1:
			b[k] += 1
		else:
			a[k] += 1
	print(a.index(-1) + b.index(-1))


T = int(input())
for t in range(T):
	n = int(input())
	xs = [int(x) for x in input().split()]
	for i in range(102):
		if xs.count(i) < 2:
			a = i
			for j in range(i, 102):
				if xs.count(j) < 1:
					b = j
					break
			break
	print(j + i)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def print_list(l):
	print(' '.join(map(str, l)))
from collections import Counter
for _ in range(N()):
	n = N()
	a = RLL()
	dic = Counter(a)
	res = 0
	for i in range(1000):
		if i not in dic:
			res += i
			break
		dic[i] -= 1
	for i in range(1000):
		if i not in dic or dic[i] == 0:
			res += i
			break
	print(res)


import sys
import math
import collections
input = sys.stdin.readline
t = int(input())
for w in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	l.sort()
	s = 0
	c = 0
	k = 0
	if l[0] == 0:
		d = collections.Counter(l)
		for i in range(101):
			if c == 2:
				break
			if i in d:
				if d[i] == 1:
					if c == 0:
						s += i
						c += 1
					else:
						k = i
			elif c == 0:
				s = 2 * i
				c = 2
			else:
				s += i
				c += 1
		if c == 1:
			print(k + 1 + s)
		else:
			print(s)
	else:
		print(0)


from collections import Counter
t = int(input())
for _ in range(t):
	N = int(input())
	X = list(map(int, input().split()))
	C = Counter(X)
	i = 0
	(a, b) = (float('inf'), float('inf'))
	while True:
		if C[i] == 0:
			a = min(i, a)
			b = min(i, b)
			break
		elif C[i] == 1:
			b = min(i, b)
		i += 1
	print(a + b)


N = int(input())
for _ in range(N):
	_ = int(input())
	A = sorted(list(map(int, input().split())))
	seta = set()
	setb = set()
	for a in A:
		if a in seta:
			setb.add(a)
		else:
			seta.add(a)
	(numa, numb) = (-1, -1)
	for i in range(101):
		if i not in seta and numa == -1:
			numa = i
		if i not in setb and numb == -1:
			numb = i
	print(numa + numb)


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	freq = [0] * 101
	for i in a:
		freq[i] += 1
	ans = 0
	for j in range(2):
		for i in range(101):
			if freq[i] == 0:
				ans += i
				break
			else:
				freq[i] -= 1
	print(ans)


import sys
T = int(sys.stdin.readline())
for _ in range(T):
	n = int(sys.stdin.readline())
	list_num = list(map(int, sys.stdin.readline().split()))
	list_num.sort(reverse=True)
	mex = [0, 0]
	while list_num:
		num = list_num.pop()
		if mex[0] == num:
			mex[0] += 1
		elif mex[1] == num:
			mex[1] += 1
	print(sum(mex))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = [0 for i in range(102)]
	for i in a:
		d[i] += 1
	count = 0
	ans = 0
	f = True
	for i in range(102):
		if f == True and d[i] == 1:
			ans += i
			count += 1
			f = False
		if d[i] == 0:
			if count == 1:
				ans += i
			else:
				ans += i + i
			break
	print(ans)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	k = [int(j) for j in input().split()]
	dic = {i: 0 for i in range(0, 101)}
	l = Counter(k)
	for i in l.keys():
		dic[i] = l[i]
	for i in range(0, 101):
		if dic[i] == 0:
			a = i
			break
	for i in range(0, 101):
		if dic[i] <= 1:
			b = i
			break
	print(a + b)


from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	dic = defaultdict(lambda : 0)
	for i in l:
		dic[i] += 1
	ans = 0
	for i in range(max(l) + 2):
		if dic[i] == 0:
			ans = i
			break
		else:
			dic[i] -= 1
	pre = ans
	for i in range(max(l) + 2):
		if dic[i] == 0:
			ans += i
			break
		else:
			dic[i] -= 1
	print(ans)


t = int(input())
ans = list()
for zxc in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	c = -1
	maxx = -1
	arr1 = list([i for i in range(202)])
	arr2 = list((i for i in range(202)))
	for i in arr:
		if i + arr1[0] >= i + arr2[0]:
			if i in arr1:
				arr1.pop(arr1.index(i))
			elif i in arr2:
				arr2.pop(arr2.index(i))
		elif i in arr2:
			arr2.pop(arr2.index(i))
		elif i in arr1:
			arr1.pop(arr1.index(i))
	ans.append(arr1[0] + arr2[0])
for z in ans:
	print(z)


import math
from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if 0 not in a:
		print(0)
	elif a.count(0) == 1:
		for i in range(1, 101):
			if i not in a:
				print(i)
				break
	else:
		an = 10 ** 5
		for i in range(1, 101):
			k = a.count(i)
			if k == 1:
				an = min(i, an)
			elif k == 0:
				if an != 10 ** 5:
					print(an + i)
					break
				else:
					print(2 * i)
					break


for i in range(int(input())):
	m = int(input())
	a = list(map(int, input().split(' ')))
	a.sort()
	if a.count(0) == 0:
		print(0)
	elif a.count(0) == 1:
		for j in range(len(a) + 1):
			if a.count(j) == 0:
				print(j)
				break
	else:
		sum = 0
		for k in range(len(a)):
			if a.count(k) >= 2:
				continue
			elif a.count(k) == 1 and sum == 0:
				sum += k
				continue
			elif a.count(k) == 0 and sum != 0:
				sum += k
				break
			elif a.count(k) == 0 and sum == 0:
				sum += k * 2
				break
			else:
				continue
		print(sum)


def mex(num):
	m: int = 0
	for nu in num:
		if m == nu:
			m += 1
	return m
t = int(input())
for i in range(t):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	a = []
	b = []
	y = -1
	for x in l:
		if y == x:
			b.append(x)
		else:
			a.append(x)
		y = x
	print(mex(a) + mex(b))


import sys

def I():
	return int(sys.stdin.readline().rstrip())

def LI():
	return list(map(int, sys.stdin.readline().rstrip().split()))
t = I()
for i in range(t):
	n = I()
	A = LI()
	B = [0] * 101
	for a in A:
		B[a] += 1
	ans = 0
	for j in range(101):
		if B[j] == 0:
			ans += j
			break
	for j in range(101):
		if B[j] <= 1:
			ans += j
			break
	print(ans)


from sys import stdin, stdout
import math, sys
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict, Counter
from os import path
import bisect as bi
import heapq

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def inp():
		return int(input())

	def minp():
		return map(int, input().split())
else:

	def inp():
		return int(stdin.readline())

	def minp():
		return map(int, stdin.readline().split())
for _ in range(inp()):
	n = inp()
	a = list(minp())
	if 0 not in a:
		print(0)
		continue
	a.sort()
	if a.count(0) == 1:
		for i in range(n + 1):
			if i not in a:
				flag = i
				break
		print(flag)
		continue
	flag = False
	for i in range(n + 1):
		if i not in a:
			t1 = 2 * i
			break
		elif a.count(i) == 1:
			flag = True
			t1 = i
			break
	t2 = 0
	if flag:
		for i in range(t2, n + 1):
			if i not in a:
				t2 = i
				break
	print(t1 + t2)


q = int(input())
for _ in range(q):
	n = int(input())
	ar = [int(i) for i in input().split()]
	kek = [0] * 101
	for i in range(n):
		kek[ar[i]] += 1
	(k, k1) = (-1, -1)
	for i in range(101):
		if kek[i] == 1:
			if k1 == -1:
				k1 = i
		elif kek[i] == 0:
			if k1 == -1:
				k = k1 = i
			else:
				k = i
			break
	print(k + k1)


t = int(input())
while t > 0:
	n = int(input())
	lst = list(map(int, input().split()))
	ans = 0
	for i in range(101):
		if i in lst:
			lst.remove(i)
		else:
			ans += i
			break
	for j in range(101):
		if j in lst:
			lst.remove(j)
		else:
			ans += j
			break
	print(ans)
	t -= 1


T = int(input())
for test in range(T):
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	lval = 0
	rval = 0
	for i in range(n):
		if a[i] == lval and rval == lval + 1:
			lval += 1
		if a[i] == rval:
			rval += 1
	print(lval + rval)


for _ in range(int(input())):
	l1 = int(input())
	set1 = input().split(' ')
	set2 = list(map(int, set1))
	set2.sort()
	mexB = 0
	mexA = 0
	for i in set2:
		if mexA == i:
			mexA += 1
		elif mexB == i:
			mexB += 1
	print(mexA + mexB)


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	i1 = 0
	i2 = 0
	while a.count(i1) >= 2:
		i1 += 1
		i2 += 1
	while a.count(i1) >= 1:
		i1 += 1
	print(i1 + i2)


import os
import heapq
import sys, threading
import math as mt
import operator
from copy import copy
from collections import defaultdict, deque
from io import BytesIO, IOBase
sys.setrecursionlimit(10 ** 5)

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def inpt():
	return [int(k) for k in input().split()]

def main():
	for _ in range(int(input())):
		n = int(input())
		ar = inpt()
		ar.sort()
		d = defaultdict(int)
		for i in ar:
			d[i] += 1
		ans = 0
		ct = 0
		(mx1, mx2) = (10 ** 9, 10 ** 9)
		for i in range(102):
			if i not in d:
				mx1 = min(i, mx1)
				break
			elif d[i] == 1:
				mx2 = min(i, mx2)
		if mx2 == 10 ** 9:
			print(2 * mx1)
		else:
			print(mx1 + mx2)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from collections import *
for _ in range(int(input())):
	N = int(input())
	A = list(map(int, input().split()))
	dic = defaultdict(int)
	for i in A:
		dic[i] += 1
	ans = 0
	check1 = -1
	flag = 0
	for i in range(0, 101):
		if dic[i] == 0:
			ans += i
			break
		else:
			dic[i] -= 1
	flag = 0
	for i in range(0, 101):
		if dic[i] == 0:
			ans += i
			break
		else:
			dic[i] -= 1
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	v = [0] * 110
	for u in map(int, input().split()):
		v[u] += 1
	mx = 0
	for i in range(0, 110):
		if v[i] < 2:
			mx = i
			break
	if v[mx] == 0:
		mx = 2 * mx
	else:
		for i in range(mx + 1, 110):
			if v[i] < 1:
				mx += i
				break
	print(mx)


n = int(input())
for i in range(n):
	x = int(input())
	s = list(map(int, input().split()))[:x]
	s.sort()
	a = []
	b = []
	j = 2
	while j < len(s) + 1:
		if s[j - 2] == s[j - 1]:
			a.append(s[j - 2])
			b.append(s[j - 1])
			j += 2
		else:
			a.append(s[j - 2])
			j += 1
	a.append(s[len(s) - 1])
	mexA = 0
	mexB = 0
	if len(a) > 0:
		for k in range(max(a) + 2):
			if k not in a:
				mexA = k
				break
	if len(b) > 0:
		for k in range(max(b) + 2):
			if k not in b:
				mexB = k
				break
	print(mexA + mexB)


from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	cnt = Counter(a)
	(num1, num2) = (-1, -1)
	(num1_modded, num2_modded) = (False, False)
	for i in range(101):
		if cnt[i] >= 2:
			continue
		if cnt[i] == 1:
			if not num1_modded:
				num1_modded = True
				num1 = i
		if cnt[i] == 0:
			if num1_modded:
				num2 = i
				num2_modded = True
			else:
				num1_modded = num2_modded = True
				num1 = num2 = i
		if num1_modded and num2_modded:
			break
	print(num1 + num2)


t = int(input())
for i in range(t):
	n = int(input())
	list1 = list(map(int, input().split()))
	list2 = []
	for j in list1:
		if j not in list2:
			list2.append(j)
	for j in list2:
		list1.remove(j)
	for j in range(0, 101):
		if j not in list2:
			val1 = j
			break
	for j in range(0, 101):
		if j not in list1:
			val2 = j
			break
	print(val1 + val2)


def mex(l):
	s = set(l)
	for i in range(len(l) + 1):
		if i not in s:
			return i
n = int(input())
for _ in range(n):
	f = int(input())
	l = list(map(int, input().split()))[:]
	x = [0] * 102
	for i in set(l):
		x[i] = l.count(i)
	for i in range(len(x)):
		if x[i] <= 1:
			k = i
			break
	print(mex(l) + k)


T = int(input())

def mex(l):
	ret = 0
	while 1:
		if l.count(ret) == 0:
			return ret
		ret += 1
for _ in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	l = [-1]
	for i in range(n):
		if a[i] == l[-1] + 1:
			l.append(a[i])
			a[i] = -1
	a = sorted(a)
	res = l[-1] + 1
	res += mex(a)
	print(res)


def solution(hmp, mx):
	c = -1
	a = 0
	b = 0
	for i in range(0, mx + 2):
		if hmp[i] == 0:
			a = i
			c = i
			break
	for i in range(0, mx + 2):
		if hmp[i] <= 1:
			b = i
			break
	return a + b
t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	arr = [int(x) for x in input().split()]
	hmp = [0 for x in range(101)]
	for a in arr:
		hmp[a] += 1
	print(solution(hmp, max(arr)))


import sys
import math
input = sys.stdin.readline
from collections import deque
from queue import LifoQueue

def binary_search(a, n):
	L = 0
	R = len(a) - 1
	while L <= R:
		mid = L + (R - L) // 2
		if a[mid] == n:
			return mid
		elif a[mid] < n:
			L = mid + 1
		else:
			R = mid - 1
	return -1
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	c = [a[0]]
	I = [0]
	for i in range(n):
		if c[-1] != a[i] and a[i] == c[-1] + 1:
			c.append(a[i])
			I.append(i)
	k = 0
	for i in I:
		a.pop(i - k)
		k += 1
	a = list(set(a))
	a.sort()
	ans = 0
	for i in range(len(a)):
		if i != a[i]:
			if i - 1 >= 0:
				ans += a[i - 1] + 1
			else:
				ans += 0
			break
		elif i == len(a) - 1:
			ans += a[i] + 1
	for i in range(len(c)):
		if i != c[i]:
			if i - 1 >= 0:
				ans += c[i - 1] + 1
			else:
				ans += 0
			break
		elif i == len(c) - 1:
			ans += c[i] + 1
	print(ans)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	a = 0
	b = 0
	i = 0
	while a in arr:
		arr.remove(a)
		a += 1
	while b in arr:
		arr.remove(b)
		b += 1
	print(a + b)


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	A.sort()
	cnt = [0 for i in range(101)]
	for i in A:
		cnt[i] += 1
	ans1 = -1
	ans2 = -1
	p = 0
	for i in range(101):
		if cnt[p] == 0:
			ans1 = p
			break
		p += 1
	p = 0
	for i in range(101):
		if cnt[p] == 1 or cnt[p] == 0:
			ans2 = p
			break
		p += 1
	print(ans1 + ans2)


from collections import *
for _ in range(int(input())):
	n = int(input())
	l = [*map(int, input().split())]
	l.sort()
	dic = Counter(l)
	arr = set()
	array = set()
	for i in range(0, 101):
		if i in dic and dic[i] > 1:
			arr.add(i)
			array.add(i)
		elif i in dic:
			arr.add(i)
	ans = -1
	for i in range(0, 101):
		if i not in arr:
			ans = i
			break
	if ans == -1:
		ans = 101
	val = ans
	flag = False
	for i in range(0, 101):
		if i not in array:
			ans += i
			flag = True
			break
	if ans == val and (not flag):
		ans += 101
	print(ans)


n = int(input())
for i in range(n):
	m = int(input())
	a = [int(i) for i in input().split()]
	l = []
	l1 = []
	d = set(a)
	first = 0
	second = 0
	for j in d:
		if a.count(j) == 1:
			l.append(j)
		else:
			l.append(j)
			l1.append(j)
	for j in range(0, 101):
		if j not in l:
			first = j
			break
	for j in range(0, 101):
		if j not in l1:
			second = j
			break
	print(first + second)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	(l, r) = (0, 0)
	for i in a:
		if l == i:
			l += 1
		elif r == i:
			r += 1
	print(l + r)


t = int(input())

def mex(setter):
	a = set(range(0, 101))
	return min(a - setter)
for i in range(t):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	A = set(a)
	B = set()
	for elem in a:
		if a.count(elem) > 1:
			B.add(elem)
	minimum = mex(A) + mex(B)
	print(minimum)


for k in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	x = 0
	y = 0
	for i in a:
		if x == i:
			x += 1
		elif y == i:
			y += 1
	print(x + y)


for _ in range(int(input())):
	n = int(input())
	c = list(map(int, input().split()))
	d = {}
	for i in c:
		d.setdefault(i, 0)
		d[i] += 1
	c = sorted(set(c))
	(r, i) = (0, 0)
	ans = []
	(a1, a2) = (-1, -1)
	while i < len(c):
		if c[i] != r:
			a1 = r
			break
		i += 1
		r += 1
	if a1 == -1:
		a1 = r
	a2 = r
	i = 0
	r = 0
	while i < len(c):
		if c[i] == r and d[c[i]] <= 1:
			a2 = c[i]
			break
		i += 1
		r += 1
	print(a1 + a2)


import sys, threading

def inpt():
	return sys.stdin.readline().rstrip()

def read():
	return [int(x) for x in inpt().split()]

def mex(a):
	for i in range(107):
		if i not in a:
			return i

def main():
	(_T_,) = read()
	for _t_ in range(_T_):
		(n,) = read()
		ar = read()
		a = set()
		b = set()
		vis = set()
		for i in ar:
			if i not in vis:
				vis.add(i)
				a.add(i)
			else:
				b.add(i)
		print(mex(a) + mex(b))
if 0:
	sys.setrecursionlimit(10 ** 7)
	threading.stack_size(10 ** 8)
	threading.Thread(target=main).start()
else:
	main()


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = [int(_) for _ in input().split(' ')]
	di = {}
	dx = {}
	dy = {}
	for i in range(0, 102):
		di[i] = 0
		dx[i] = 0
		dy[i] = 0
	for i in a:
		di[i] += 1
	ans = 0
	x = []
	y = []
	a.sort()
	for el in a:
		if di[el] > 1:
			dy[el] = 1
			dx[el] = di[el] - 1
		elif di[el] == 1:
			dx[el] = 1
	for i in range(0, 102):
		if dy[i] == 0:
			ans += i
			break
	for i in range(0, 102):
		if dx[i] == 0:
			ans += i
			break
	print(ans)


PI = 3.141592653589793
INF = 999999999
MOD = 1000000007

def add(x, y):
	return (x + y) % MOD

def sub(x, y):
	return (x - y + MOD) % MOD

def mul(x, y):
	return x * y % MOD

def gcd(x, y):
	if y == 0:
		return x
	return gcd(y, x % y)

def lcm(x, y):
	return x * y // gcd(x, y)

def power(x, y):
	res = 1
	x %= MOD
	while y != 0:
		if y & 1:
			res = mul(res, x)
		y >>= 1
		x = mul(x, x)
	return res

def mod_inv(n):
	return power(n, MOD - 2)

def prob(p, q):
	return mul(p, power(q, MOD - 2))

def ii():
	return int(input())

def li():
	return [int(i) for i in input().split()]

def ls():
	return [i for i in input().split()]

def mex(l):
	for i in range(len(l)):
		if l[i] != i:
			return i
	return len(l)
for t in range(ii()):
	t += 1
	n = ii()
	a = li()
	f = [0 for i in range(101)]
	for i in a:
		f[i] += 1
	x = []
	y = []
	for i in range(101):
		if f[i] == 1:
			x.append(i)
		elif f[i] > 1:
			x.append(i)
			y.append(i)
	x.sort()
	y.sort()
	print(mex(x) + mex(y))


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
import threading
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	mx = max(a) + 1
	mn = 0
	ch = 1
	d = dict()
	for i in a:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	for i in range(max(a) + 1):
		if i not in d:
			mx = i
			break
		if ch == 1 and d[i] > 1:
			mn = i + 1
		if d[i] == 1:
			ch = 0
	print(mx + mn)


t = int(input())
while t > 0:
	n = int(input())
	l = list(map(int, input().split()))
	ll = set(l)
	nll = ll
	lk = []
	for i in range(n):
		if l[i] in nll:
			nll = nll - {l[i]}
		else:
			lk.append(l[i])
	lll = list(ll)
	l = set(l)
	ul = []
	for i in range(max(lll) + 2):
		ul.append(i)
	ul = set(ul)
	m1 = min(list(ul - ll))
	ul = []
	if lk == []:
		m2 = 0
	else:
		for i in range(max(lk) + 2):
			ul.append(i)
		ul = set(ul)
		m2 = min(list(ul - set(lk)))
	print(m1 + m2)
	t = t - 1


def computeGCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
for _ in range(int(input())):
	n = int(input())
	arr = [int(j) for j in input().split()]
	arr.sort()
	dic = dict()
	for i in range(0, 101):
		dic[i] = 0
	for i in arr:
		dic[i] += 1
	ans = 0
	flag = 0
	for i in dic:
		if dic[i] >= 2:
			continue
		elif dic[i] == 1 and flag == 0:
			ans += i
			flag = 1
		elif flag == 0 and dic[i] == 0:
			ans = 2 * i
			break
		elif flag == 1 and dic[i] == 1:
			continue
		elif flag == 1 and dic[i] == 0:
			ans += i
			break
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	res = 0
	step = 2
	for i in range(101):
		num = a.count(i)
		if step == 2:
			if num >= 2:
				res += 2
			elif num == 1:
				res += 1
				step = 1
			else:
				step = 0
		elif step == 1:
			if num >= 1:
				res += 1
			else:
				step = 0
	print(res)


from sys import stdin, exit, setrecursionlimit
from collections import deque
input = stdin.readline
lmi = lambda : list(map(int, input().split()))
mi = lambda : map(int, input().split())
si = lambda : input().strip('\n')
ssi = lambda : input().strip('\n').split()
mod = 10 ** 9 + 7
for _ in range(int(input())):
	n = int(input())
	a = lmi()
	tot = 0
	for i in range(n + 1):
		if a.count(i) < 2:
			tot += i
			break
	for i in range(n + 1):
		if a.count(i) < 1:
			tot += i
			break
	print(tot)


for _ in range(int(input())):
	(n, lst, cnt, ans) = (int(input()), sorted(map(int, input().split(' '))), 0, 0)
	for i in range(101):
		if i in lst:
			lst.remove(i)
		else:
			ans += i
			break
	for i in range(101):
		if i in lst:
			lst.remove(i)
		else:
			ans += i
			break
	print(ans)


t = int(input())
for case in range(t):
	n = int(input())
	List = [int(j) for j in input().split(' ')]
	List_1 = set(List)
	k = 0
	for i in List_1:
		if i != k:
			break
		else:
			k += 1
	List.sort()
	List_3 = []
	for i in range(1, n):
		if List[i] == List[i - 1]:
			if List[i] not in List_3:
				List_3.append(List[i])
	a = 0
	for i in List_3:
		if i != a:
			break
		else:
			a += 1
	print(a + k)


t = int(input())
while t > 0:
	n = int(input())
	arr = list(map(int, input().split(' ')))
	ma = 0
	mb = 0
	m = {}
	for i in range(n):
		if arr[i] not in m:
			m[arr[i]] = 0
		m[arr[i]] += 1
	flagUpdate = False
	for i in range(101):
		if i not in m:
			break
		if m[i] >= 2:
			ma += 1
			if not flagUpdate:
				mb += 1
		elif m[i] == 1:
			ma += 1
			flagUpdate = True
	print(ma + mb)
	t -= 1


import bisect
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))
for _ in range(I()):
	n = I()
	arr = LI()
	arr.sort()
	c = 0
	if arr[0] != 0:
		print(0)
	else:
		dic = Counter(arr)
		brr = []
		crr = []
		for i in dic.keys():
			if dic[i] >= 2:
				brr += [i]
				crr += [i]
			elif dic[i] == 1:
				brr += [i]
		flag = 1
		for i in range(len(crr)):
			if i != crr[i]:
				c += i
				flag = 0
				break
			if i == len(crr) - 1 and flag:
				c += i + 1
		flag = 1
		for j in range(len(brr)):
			if j != brr[j]:
				c += j
				flag = 0
				break
			if j == len(brr) - 1 and flag:
				c += j + 1
		print(c)


def f(l):
	a = 0
	b = 0
	for i in l:
		if i == a:
			a = a + 1
		elif i == b:
			b = b + 1
	return a + b
t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	l = sorted(s)
	print(f(l))


import sys
from math import sqrt, gcd, ceil, log, floor
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
input = sys.stdin.readline
read = lambda : list(map(int, input().strip().split()))

def main():
	ans_ = []
	for _ in range(int(input())):
		n = int(input())
		arr = Counter(read())
		ans = 0
		for i in range(101):
			if arr[i] < 2:
				ans += i
				break
		for i in range(101):
			if arr[i] == 0:
				ans += i
				break
		ans_.append(ans)
	print('\n'.join(map(str, ans_)))
main()


import sys
sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]
from collections import Counter
for _ in range(II()):
	n = II()
	aa = LI()
	ac = Counter(aa)
	x = y = -1
	for a in range(101):
		if x == -1 and ac[a] < 2:
			x = a
		if y == -1 and ac[a] < 1:
			y = a
	print(x + y)


for _ in range(int(input())):
	n = int(input())
	L = sorted(list(map(int, input().split())))
	(c, t, flag) = (0, None, True)
	while True:
		if c not in L:
			if t == None:
				print(2 * c)
			else:
				print(t + c)
			break
		elif L.count(c) == 1 and flag:
			t = c
			flag = False
		c += 1


for infiniteInput in range(int(input())):
	firstInput = int(input())
	listOfSubset = list(map(int, input().split()))
	listOfSubset.sort()
	subsetFirstCount = 0
	subsetSecondCount = 0
	for i in listOfSubset:
		if subsetFirstCount == i:
			subsetFirstCount += 1
		elif subsetSecondCount == i:
			subsetSecondCount += 1
	print(subsetFirstCount + subsetSecondCount)


n = int(input())
for _ in range(n):
	mex = []
	s = int(input())
	myset = list(map(int, input().split()))
	for i in range(101):
		if myset.count(i) == 0 and len(mex) == 0:
			mex.append(i + i)
			break
		if myset.count(i) < 2 - len(mex):
			mex.append(i)
			if len(mex) == 2:
				break
	print(sum(mex))


import collections
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	minm = min(a)
	if minm != 0:
		print(0)
		continue
	dic = {}
	for i in a:
		if i in dic:
			dic[i] += 1
		else:
			dic[i] = 1
	dic = collections.OrderedDict(sorted(dic.items()))
	k = 0
	for j in dic:
		if j != k:
			break
		else:
			dic[j] = dic[j] - 1
			k += 1
	ans1 = k
	k2 = 0
	if dic[0] > 0:
		for j in dic:
			if j != k2 or dic[j] <= 0:
				break
			else:
				dic[j] = dic[j] - 1
				k2 += 1
	ans2 = k2
	print(ans1 + ans2)


from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	d = Counter(arr)
	c = 0
	ppos = None
	for (pos, i) in enumerate(d):
		if i == c and d[i] > 1:
			c += 1
		else:
			ppos = pos
			break
	if ppos == None:
		print(2 * c)
	else:
		v = 0
		k = list(d.keys())
		if k[ppos] != c:
			v = 2 * c
		else:
			v = c
			c += 1
			for i in range(ppos + 1, len(k)):
				if k[i] == c:
					c += 1
				else:
					break
			v += c
		print(v)


def ans_if_list(ans):
	if isinstance(ans, str):
		return ans
	elif isinstance(ans, int):
		return ans
	else:
		return ' '.join((str(ans[i]) for i in range(len(ans))))

def input_list(typ='int'):
	if typ == 'int':
		return list(map(int, input().split()))
	elif typ == 'str':
		return list(input())

def hashmapuh(num_list_):
	num_dict_ = {}
	for num in num_list_:
		if num not in num_dict_.keys():
			num_dict_[num] = 1
		else:
			num_dict_[num] += 1
	return num_dict_
t = int(input())
for q in range(t):
	l = int(input())
	ls = input_list()
	a = list(range(0, 101))
	b = list(range(0, 101))
	for i in ls:
		cond1 = i in a
		cond2 = i in b
		if cond1 and cond2:
			a.remove(i)
		elif cond1 and (not cond2):
			a.remove(i)
		elif not cond1 and cond2:
			b.remove(i)
		else:
			pass
	ans = min(a) + min(b)
	print(ans)


import sys
T = int(sys.stdin.readline().strip())
for t in range(0, T):
	n = int(sys.stdin.readline().strip())
	a = list(map(int, sys.stdin.readline().strip().split()))
	a.sort()
	m1 = 0
	m2 = 0
	for i in range(0, n):
		if a[i] == m1:
			m1 = m1 + 1
		elif a[i] == m2:
			m2 = m2 + 1
	print(m1 + m2)


from collections import Counter

def single(i, c, s, arr):
	for j in range(i + 1, max(arr) + 2):
		if j not in c:
			return s + j
		elif c[j] >= 1:
			continue
		else:
			return s + j

def fun(arr):
	c = Counter(arr)
	s = 0
	t = 2
	for i in range(max(arr) + 2):
		if i in c:
			if c[i] >= 2:
				continue
			elif c[i] == 1:
				if t > 0:
					t -= 1
					s += i
					if t == 1:
						return single(i, c, s, arr)
				else:
					return s
			else:
				s += t * i
				return s
		else:
			s += t * i
			return s
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	print(fun(arr))


from collections import Counter

def find_ans(n):
	s = list(map(int, input().split()))
	s = sorted(dict(Counter(s)).items())
	a = []
	b = []
	for i in s:
		if i[1] >= 2:
			a.append(i[0])
			b.append(i[0])
		elif i[1] < 2:
			a.append(i[0])
	qa = 1111111110
	qb = 1111111110
	for i in range(101):
		if i not in a:
			qa = min(i, qa)
		if i not in b:
			qb = min(qb, i)
	print(qa + qb)
for _ in range(int(input())):
	find_ans(int(input()))


def mex(l):
	if l == []:
		return 0
	l.append(0)
	for i in range(len(l)):
		if i == l[i]:
			pass
		else:
			return i
t = int(input())
for i in range(t):
	(n, a) = (int(input()), list(map(int, input().split())))
	if n == 0:
		print(0)
	elif n == 1:
		if a[0] == 0:
			print(1)
		else:
			print(0)
	else:
		i = 0
		a.sort()
		(la, lb) = ([], [])
		while i < n - 1:
			if a[i] == a[i + 1]:
				if a[i] not in la:
					la.append(a[i])
				if a[i + 1] not in lb:
					lb.append(a[1 + i])
				i += 2
			else:
				if a[i] not in la:
					la.append(a[i])
				i += 1
		la.append(a[-1])
		print(mex(la) + mex(lb))


def input_int():
	return int(input())

def input_int_list():
	return list(map(int, input().split()))

def input_int_map():
	return map(int, input().split())

def run():
	q_num = input_int()
	for i in range(q_num):
		num_count = input_int()
		nums = input_int_list()
		nums.sort()
		first_num = -1
		second_num = -1
		is_first_end = False
		for i in range(num_count):
			num_count = nums.count(i)
			if num_count == 1:
				is_first_end = True
			if not is_first_end and num_count >= 2:
				first_num = i
			if num_count >= 1:
				second_num = i
			else:
				break
		print(first_num + second_num + 2)
run()


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(_) for _ in input().split()]
	num = [0] * 101
	for i in a:
		num[i] += 1
	ans = 0
	mode = True
	for i in range(101):
		if num[i] >= 2:
			if mode:
				ans += 2
			else:
				ans += 1
			continue
		elif num[i] == 1:
			mode = False
			ans += 1
		else:
			break
	print(ans)


def mex(sett):
	if len(sett) == 0:
		return 0
	sett.sort()
	sett = list(dict.fromkeys(sett))
	test = 0
	for i in range(len(sett) + 1):
		if test in sett:
			test += 1
		else:
			return test
t = int(input())
for i in range(t):
	length = int(input())
	the_set = list(map(int, input().split()))
	if len(the_set) == 1:
		print(mex(the_set))
	else:
		A = []
		B = []
		the_set.sort()
		A.append(the_set[0])
		for i in range(1, len(the_set)):
			if the_set[i] == the_set[i - 1]:
				B.append(the_set[i])
			else:
				A.append(the_set[i])
		print(mex(A) + mex(B))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	max_a = max(a)
	i = 0
	result = 0
	max_add = 2
	while i <= max_a:
		count = a.count(i)
		if count >= max_add:
			result += max_add
		else:
			max_add -= 1
			if count == 0 or max_add == 0:
				break
			result += max_add
		i += 1
	print(result)


import math
from sys import stdin, stdout

def solve():
	t = int(input())
	while t > 0:
		t -= 1
		n = int(input())
		arr = list(map(int, input().split()))
		brr = [0 for x in range(0, 111)]
		for x in arr:
			brr[x] += 1
		ans = 0
		flag = 0
		for x in range(0, 111):
			if brr[x] == 1:
				if flag == 0:
					ans += x
					flag = 1
			elif brr[x] == 0:
				if flag == 0:
					print(2 * x)
					flag = 2
					break
				elif flag == 1:
					print(ans + x)
					flag = 2
					break
solve()


import heapq as hq
from heapq import heappop, heappush
from collections import deque, defaultdict, Counter
from sys import stdin, stdout

def inp():
	return int(stdin.readline())

def inlt():
	return list(map(int, stdin.readline().split()))

def insr():
	return list(stdin.readline().strip())

def invr():
	return map(int, stdin.readline().split())

def subset_sum_count(arr, n, sum):
	dp = [[0 for _ in range(sum + 1)] for _ in range(n + 1)]
	for i in range(n + 1):
		for j in range(sum + 1):
			if j == 0:
				dp[i][j] = 1
			elif arr[i - 1] <= j:
				dp[i][j] = dp[i - 1][j - arr[i - 1]] + dp[i - 1][j]
			else:
				dp[i][j] = dp[i - 1][j]
	return dp[n][sum]

def binary_search(func, lo, hi, abs_prec=1e-07):
	while abs(hi - lo) > abs_prec:
		mi = lo + (hi - lo) / 2
		if func(mi):
			hi = mi
		else:
			lo = mi
	return (lo + hi) / 2

def ternary_search(func, lo, hi, abs_prec=1e-07):
	while abs(hi - lo) > abs_prec:
		lo_third = lo + (hi - lo) / 3
		hi_third = hi - (hi - lo) / 3
		if func(lo_third) < func(hi_third):
			lo = lo_third
		else:
			hi = hi_third
	return (lo + hi) / 2

def discrete_binary_search(func, lo, hi):
	while lo < hi:
		mi = lo + (hi - lo) // 2
		if func(mi):
			hi = mi
		else:
			lo = mi + 1
	return lo

def discrete_ternary_search(func, lo, hi):
	while lo <= hi:
		lo_third = lo + (hi - lo) // 3
		hi_third = lo + (hi - lo) // 3 + (1 if 0 < hi - lo < 3 else (hi - lo) // 3)
		if func(lo_third) < func(hi_third):
			lo = lo_third + 1
		else:
			hi = hi_third - 1
	return lo
	return -1

def right_rotate(a, s):
	return a[s:] + a[:s]

def dec_to_bin(x):
	return int(bin(x)[2:])

def str_to_integer_list(n):
	a = []
	for i in range(len(n)):
		a.append(int(n[i]))
	return a

def list_to_str(l):
	s = ''
	for i in l:
		s += str(i)
	return s

def dijkstra(s, N, E):
	visited = set()
	dist = {}
	for i in range(1, N + 1):
		dist[i] = 1 << 29
	queue = [(dist[i], i) for i in range(1, N + 1)]
	hq.heappush(queue, (0, s))
	dist[s] = 0
	while queue:
		(d, u) = hq.heappop(queue)
		if u in visited:
			continue
		for t in E[u]:
			(v, r) = t
			if dist[v] > d + r:
				dist[v] = d + r
				hq.heappush(queue, (dist[v], v))
		visited.add(u)
	return dist

def prime_sieve(n):
	flag = n % 6 == 2
	sieve = bytearray((n // 3 + flag >> 3) + 1)
	for i in range(1, int(n ** 0.5) // 3 + 1):
		if not sieve[i >> 3] >> (i & 7) & 1:
			k = 3 * i + 1 | 1
			for j in range(k * k // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
			for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
	return sieve

def prime_list(n):
	res = []
	if n > 1:
		res.append(2)
	if n > 2:
		res.append(3)
	if n > 4:
		sieve = prime_sieve(n + 1)
		res.extend((3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not sieve[i >> 3] >> (i & 7) & 1))
	return res

def dijkstra(n, graph, start):
	(dist, parents) = ([float('inf')] * n, [-1] * n)
	dist[start] = 0
	queue = [(0, start)]
	while queue:
		(path_len, v) = heappop(queue)
		if path_len == dist[v]:
			for (w, edge_len) in graph[v]:
				if edge_len + path_len < dist[w]:
					(dist[w], parents[w]) = (edge_len + path_len, v)
					heappush(queue, (edge_len + path_len, w))
	return (dist, parents)

def path(start, end, parent):
	path = [end]
	while path[-1] != start:
		path.append(parent[path[-1]])
	path.reverse()
	return path

def bfs(graph, start, goal):
	if start == goal:
		return [start]
	visited = {start}
	queue = deque([(start, [])])
	while queue:
		(current, path) = queue.popleft()
		visited.add(current)
		for neighbor in graph[current]:
			if neighbor == goal:
				return path + [current, neighbor]
			if neighbor in visited:
				continue
			queue.append((neighbor, path + [current]))
			visited.add(neighbor)
	return None

def fillPrefixSum(arr, n, prefixSum):
	prefixSum[0] = arr[0]
	for i in range(1, n):
		prefixSum[i] = prefixSum[i - 1] + arr[i]

def check(a, ind, d1):
	beg = a[:ind + 1]
	end = a[ind + 1:]
	d = []
	c = 0
	for i in end:
		if i - d1 in beg:
			c += 1
	return c
import os
import sys
from io import BytesIO, IOBase

def DecimalToBinary(n):

	def helper(n):
		if n == 0:
			return ''
		else:
			if n % 2 == 1:
				binaryDigit = '1'
			else:
				binaryDigit = '0'
			return helper(n // 2) + binaryDigit
	if n == 0:
		result = '0'
	else:
		result = helper(n)
	return result

def p(board):
	for i in range(8):
		s = ''
		for j in range(8):
			s += board[i][j]
		print(s)

def binaryToDecimal(n):
	return int(n, 2)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def solve(a, b):
	x = DecimalToBinary(a)
	y = DecimalToBinary(b)
	z = x + y
	l = y + x
	r = binaryToDecimal(z) - binaryToDecimal(l)
	return r

def mostFrequent(arr, n):
	arr.sort()
	max_count = 1
	res = arr[0]
	curr_count = 1
	for i in range(1, n):
		if arr[i] == arr[i - 1]:
			curr_count += 1
		else:
			if curr_count > max_count:
				max_count = curr_count
				res = arr[i - 1]
			curr_count = 1
	if curr_count > max_count:
		max_count = curr_count
		res = arr[n - 1]
	return res
from bisect import bisect_right, bisect_left

def lds(arr, n):
	lds = [0] * n
	max = 0
	for i in range(n):
		lds[i] = 1
	for i in range(1, n):
		for j in range(i):
			if arr[i] < arr[j] and lds[i] < lds[j] + 1:
				lds[i] = lds[j] + 1
	for i in range(n):
		if max < lds[i]:
			max = lds[i]
	return max
import math

def prefix(a):
	pre = []
	pre.append(a[0])
	for i in range(1, len(a)):
		pre.append(pre[i - 1] + a[i])
	return pre

def solve(n, x, size):
	res = 10000000
	if n == 0:
		return 0
	if size == 0:
		return 0
	for i in x:
		res = 1 + min(res, solve(n - i, x, size - 1))
		return res

def main():
	for _ in range(inp()):
		n = inp()
		a = inlt()
		c = [0 for _ in range(101)]
		ans = 0
		pp = 0
		qq = 0
		for i in a:
			c[int(i)] += 1
		for i in range(101):
			if c[i] > 0:
				c[i] -= 1
			else:
				pp = i
				break
		for i in range(101):
			if c[i] > 0:
				c[i] -= 1
			else:
				qq = i
				break
		print(pp + qq)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	hash1 = [0] * 101
	for i in arr:
		hash1[i] += 1
	f_done = False
	ans = 0
	for i in range(101):
		if hash1[i] > 1:
			continue
		if hash1[i] == 0:
			if not f_done:
				ans = 2 * i
			else:
				ans += i
			break
		elif hash1[i] == 1 and (not f_done):
			f_done = True
			ans = i
	print(ans)


import sys, io, os, time
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect, math, heapq
alphabet = 'abcdefghijklmnopqrstuvwxyz'
input = sys.stdin.readline

def mex(a):
	for i in range(101):
		if i not in a:
			return i
for ii in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	a1 = []
	a2 = []
	count = Counter(arr)
	for (k, v) in count.items():
		if v > 0:
			a1.append(k)
		v -= 1
		if v > 0:
			a2.append(k)
	print(mex(a1) + mex(a2))


for i in range(int(input())):
	size = int(input())
	count = 0
	arr = [int(i) for i in input().split(' ')]
	counting_arr = [0] * int(max(arr) + 2)
	for i in arr:
		counting_arr[i] += 1
	for i in range(len(counting_arr)):
		if counting_arr[i] >= 1:
			counting_arr[i] -= 1
		else:
			count += i
			break
	for i in range(len(counting_arr)):
		if counting_arr[i] >= 1:
			counting_arr[i] -= 1
		else:
			count += i
			break
	print(count)


for adfsda in range(int(input())):
	n = int(input())
	nums = [0] * 110
	for i in list(map(int, input().split())):
		nums[i] += 1
	cs = True
	ans = 0
	for i in nums:
		if i > 1 and cs:
			ans += 2
		elif i == 1 or (i > 1 and (not cs)):
			cs = False
			ans += 1
		else:
			break
	print(ans)


def inp():
	return int(input())
for _ in range(inp()):
	n = inp()
	arr = list(map(int, input().split(' ')))
	if 0 not in arr:
		print(0)
	else:
		a = []
		b = []
		ans = []
		for i in arr:
			if i not in a:
				a.append(i)
			else:
				b.append(i)
		for j in range(n):
			if j not in a:
				ans.append(j)
				break
		if len(ans) == 0:
			ans.append(max(a) + 1)
		if len(b) > 0:
			for j in range(n):
				if j not in b:
					ans.append(j)
					break
		else:
			ans.append(0)
		print(sum(ans))


for __ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	kek = [0] * 200
	for elem in ar:
		kek[elem] += 1
	(a, b) = (0, 0)
	flag = True
	for i in range(200):
		if flag and kek[i] >= 2:
			a += 1
			b += 1
		else:
			flag = False
			if kek[i] >= 1:
				a += 1
			else:
				break
	print(a + b)


for i in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	x.sort()
	lst = list()
	lst1 = list()
	c3 = 0
	c2 = 0
	for i in range(n):
		if x[i] in lst and x[i] in lst1:
			continue
		if x[i] not in lst:
			lst.append(x[i])
		else:
			lst1.append(x[i])
	for i in range(len(lst)):
		if i != lst[i]:
			c = i
			c2 = 1
			break
	if c2 != 1:
		if len(lst) == 0:
			c = 0
		else:
			c = lst[-1] + 1
	for i in range(len(lst1)):
		if i != lst1[i]:
			c1 = i
			c3 = 1
			break
	if c3 != 1:
		if len(lst1) == 0:
			c1 = 0
		else:
			c1 = lst1[-1] + 1
	print(c + c1)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	a2 = list(set(a))
	ans = 0
	for i in range(len(a2)):
		if a2[i] != i:
			ans += i
			break
	else:
		ans += len(a2)
	for i in range(ans):
		a.remove(i)
	a2 = list(set(a))
	for i in range(len(a2)):
		if a2[i] != i:
			ans += i
			break
	else:
		ans += len(a2)
	print(ans)


from collections import defaultdict, Counter

def modinv(n, p):
	return pow(n, p - 2, p)

def main():
	for case in range(int(input())):
		n = int(input())
		arr = [int(x) for x in input().split()]
		ct = Counter(arr)
		ans = 0
		first = True
		second = True
		for i in range(101):
			if first and ct[i] == 1:
				first = False
				ans += i
				continue
			if ct[i] == 0:
				ans += i
				if first:
					ans += i
				break
		print(ans)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def run():
	n = int(input())
	nums = list(map(int, input().split()))
	ex = list(set(nums))
	ex.sort()
	ans = 0
	for i in range(101):
		if i not in ex:
			ans += i
			break
	ex = []
	for i in nums:
		if nums.count(i) > 1:
			ex.append(i)
	ex.sort()
	for i in range(101):
		if i not in ex:
			ans += i
			break
	print(ans)
for i in range(int(input())):
	run()


for _ in range(int(input())):
	n = int(input())
	data = list(map(int, input().split()))
	cnt = [0] * 101
	for x in data:
		cnt[x] += 1
	first = 0
	while True:
		if cnt[first] >= 1:
			cnt[first] -= 1
		else:
			break
		first += 1
	second = 0
	while True:
		if cnt[second] >= 1:
			cnt[second] -= 1
		else:
			break
		second += 1
	print(first + second)


t = int(input())
for ii in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	freq = {}
	for i in a:
		if i in freq:
			freq[i] += 1
		else:
			freq[i] = 1
	mex = 0
	foud = False
	printed = False
	for i in range(0, 101):
		if i in freq:
			if freq[i] >= 2:
				continue
			elif foud:
				continue
			else:
				mex += i
				foud = True
		else:
			printed = True
			if not foud:
				mex += 2 * i
				print(mex)
				break
			else:
				mex += i
				print(mex)
				break
	if not printed:
		print((max(a) + 1) * 2)


n = int(input())
for j in range(0, n):
	m = int(input())
	a = input().split()
	l = []
	p = []
	for o in range(0, m):
		if int(a[o]) not in l:
			l.append(int(a[o]))
		else:
			p.append(int(a[o]))
	b = False
	for i in range(0, len(l)):
		if i not in l:
			b = True
			break
	if b:
		s = i
	else:
		s = len(l)
	if p == []:
		print(s)
	else:
		b = False
		for i in range(0, len(p)):
			if i not in p:
				b = True
				break
		if b:
			print(s + i)
		else:
			print(s + len(p))


lst = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]
x = int(input())
for i in range(x):
	sub1 = []
	sub2 = []
	check1 = []
	check2 = []
	u = 0
	v = 0
	n = int(input())
	lst1 = [int(x) for x in input().split()]
	copy = lst1.copy()
	for j in lst1:
		sub1.append(j)
		copy.pop(0)
		for k in copy:
			if j == k:
				sub2.append(k)
		for l in lst:
			if l not in sub1:
				u = l
				break
		for m in lst:
			if m not in sub2:
				v = m
				break
	print(u + v)


from collections import Counter
for test in range(int(input())):
	n = int(input())
	arr = tuple(map(int, input().split()))
	c = Counter(arr)
	for item in c:
		if c[item] > 2:
			c[item] = 2
	A = []
	B = []
	mex1 = 0
	mex2 = 0
	for i in range(0, len(arr)):
		if i in c:
			if c[i] == 2:
				mex1 += 1
				mex2 += 1
			else:
				mex1 += 1
				break
		else:
			break
	if i in c:
		i += 1
		while i in c:
			mex1 += 1
			i += 1
	print(mex1 + mex2)


from collections import Counter
t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	arr = [int(val) for val in input().strip().split()]
	counts = Counter(arr)
	i = 0
	done = 0
	ans = 0
	while done < 2:
		if counts[i] == 0 and done == 0:
			print(i * 2)
			break
		elif counts[i] == 1 and done == 0:
			ans += i
			done += 1
		elif counts[i] < 1 and done == 1:
			ans += i
			print(ans)
			break
		i += 1


import os
import heapq
import sys, threading
import math
import bisect
import operator
from collections import defaultdict
from io import BytesIO, IOBase

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def power(x, p, m):
	res = 1
	while p:
		if p & 1:
			res = res * x % m
		x = x * x % m
		p >>= 1
	return res

def inar():
	return [int(k) for k in input().split()]

def lcm(num1, num2):
	return num1 * num2 // gcd(num1, num2)

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		arr = inar()
		freq = [0] * 101
		for i in range(n):
			freq[arr[i]] += 1
		ans = 0
		for i in range(101):
			if freq[i] > 0:
				freq[i] -= 1
				continue
			else:
				ans += i
				break
		for i in range(101):
			if freq[i] > 0:
				freq[i] -= 1
				continue
			else:
				ans += i
				break
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	elemCount = [0] * 101
	for elem in a:
		elemCount[elem] += 1
	twoMax = -1
	twoMaxEnd = False
	oneMax = -1
	for i in range(101):
		if elemCount[i] == 0:
			break
		if elemCount[i] == 1:
			oneMax = i
			twoMaxEnd = True
		if elemCount[i] >= 2 and twoMaxEnd:
			oneMax = i
		if elemCount[i] >= 2 and (not twoMaxEnd):
			oneMax = i
			twoMax = i
	print(oneMax + 1 + twoMax + 1)


def solve(arr):
	ans = 0
	arr.sort()
	m = arr[-1]
	ind = 0
	mex1 = 0
	for mex1 in range(m + 2):
		found = False
		while ind < len(arr):
			if arr[ind] == mex1:
				arr[ind] = -1
				found = True
				break
			ind += 1
		if not found:
			break
	ans += mex1
	arr = set(arr)
	mex2 = 0
	for mex2 in range(m + 2):
		if mex2 not in arr:
			break
	print(ans + mex2)
t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(i) for i in input().split()]
	solve(arr)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import gcd, ceil

def pre(s):
	n = len(s)
	pi = [0] * n
	for i in range(1, n):
		j = pi[i - 1]
		while j and s[i] != s[j]:
			j = pi[j - 1]
		if s[i] == s[j]:
			j += 1
		pi[i] = j
	return pi

def prod(a):
	ans = 1
	for each in a:
		ans = ans * each
	return ans

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
for _ in range(int(input()) if True else 1):
	n = int(input())
	a = list(map(int, input().split()))
	di = {}
	for i in a:
		di[i] = 1 if i not in di else di[i] + 1
	mex = 0
	two = 0
	twopos = True
	for i in range(n):
		if i in di:
			mex += 1
			if twopos and di[i] >= 2:
				two += 2
			else:
				two += 1
				twopos = False
		else:
			break
	if mex == n:
		print(mex)
		continue
	print(max(mex, two))


import collections
m = int(input())
while m:
	z = 0
	l = 0
	n = int(input())
	x = collections.Counter(map(int, input().split()))
	for i in range(101):
		if x[i] == 0 and z > 0:
			print(l + i)
			break
		if x[i] == 0:
			print(i * 2)
			break
		elif x[i] == 1:
			if z == 0:
				l = i
				z += 1
	m -= 1


import math
import sys
t = int(input())
pi = 3.1415
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	cnt = 0
	ans = 0
	mp = [0 for i in range(102)]
	for i in a:
		mp[i] += 1
	for i in range(102):
		if mp[i] >= 2:
			continue
		else:
			if cnt == 0:
				ans += i * (2 - mp[i])
				cnt += 2 - mp[i]
			elif mp[i] == 0:
				cnt += 1
				ans += i
			if cnt >= 2:
				break
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	i = 0
	a = 0
	b = 0
	while True:
		if i not in arr:
			a = i
			break
		else:
			arr.remove(i)
		i += 1
	i = 0
	while True:
		if i not in arr:
			b = i
			break
		else:
			arr.remove(i)
		i += 1
	print(a + b)


t = int(input())
for _ in range(t):
	n = input()
	l = [int(x) for x in input().split()]
	l.sort()
	(a, b) = (0, 0)
	for i in l:
		if i == a:
			a += 1
		elif i == b:
			b += 1
	print(a + b)


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = [int(ai) for ai in input().split()]
	occ = {}
	for ai in a:
		if ai not in occ.keys():
			occ[ai] = 1
		else:
			occ[ai] += 1
	mexA = 101
	mexB = 101
	for i in range(0, 101):
		if i not in occ:
			mexA = min(mexA, i)
			mexB = min(mexB, i)
			break
		if occ[i] == 1:
			mexB = min(mexB, i)
			continue
	print(mexA + mexB)


from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	d = dict(Counter(s))
	ma = 0
	mb = 0
	mbvisited = False
	for x in range(101):
		if x not in d:
			ma = x
			if mbvisited == False:
				mb = x
			break
		if d[x] == 1 and mbvisited == False:
			mb = x
			mbvisited = True
	print(ma + mb)


from sys import stderr
from functools import *
from itertools import *
t = int(input())
for _ in range(t):
	c = [0 for _ in range(101)]
	n = int(input())
	arr = list(map(int, input().split()))
	for a in arr:
		c[a] += 1
	a = 0
	b = 0
	for val in range(101):
		if c[val] >= 1:
			c[val] -= 1
			a = val + 1
		else:
			break
	for val in range(101):
		if c[val] >= 1:
			c[val] -= 1
			b = val + 1
		else:
			break
	print(a + b)


import sys
from collections import defaultdict, Counter as CC
from math import sqrt, ceil, floor, log2
INF = float('inf')
MOD = 10 ** 9 + 7
read = lambda : [int(s) for s in sys.stdin.readline().split()]

def mex(arr):
	n = len(arr)
	if n == 0:
		return 0
	st = set(arr)
	for i in range(n):
		if i not in st:
			return i
	return n

def solve():
	(n,) = read()
	a = read()
	d = CC(a)
	a1 = []
	a2 = []
	for i in d:
		if d[i] > 1:
			a1.append(i)
			a2.extend((d[i] - 1) * [i])
		elif d[i] == 1:
			a1.append(i)
	print(mex(a1) + mex(a2))
_ = 1
_ = int(input())
while _:
	solve()
	_ -= 1


t = int(input())
while t:
	t -= 1
	n = int(input())
	l = list(map(int, input().split()))
	d = dict()
	for i in l:
		if i not in d:
			d[i] = 1
		else:
			d[i] += 1
	one = None
	two = None
	for i in range(102):
		if i not in d:
			one = i
			break
		elif d[i] == 1:
			d.pop(i)
	for i in range(102):
		if i not in d:
			two = i
			break
	print(one + two)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	a = [0] * 102
	b = [0] * 102
	for j in l:
		if a[j] > 0:
			b[j] += 1
		else:
			a[j] += 1
	print(a.index(0) + b.index(0))


from sys import stdin, stdout
from collections import defaultdict
input = lambda : stdin.readline().rstrip()
for _ in range(int(input())):
	n = int(input())
	lst = [int(i) for i in input().split()]
	dict1 = defaultdict(int)
	for i in lst:
		dict1[i] += 1
	lst1 = []
	lst2 = []
	for i in dict1:
		if dict1[i] > 1:
			lst1.append(i)
			lst2.append(i)
		else:
			lst1.append(i)
	lst1.sort()
	lst2.sort()
	sum1 = 0
	for i in range(0, 103):
		try:
			if lst1[i] != i:
				sum1 += i
				break
		except:
			sum1 += i
			break
	for i in range(0, 103):
		try:
			if lst2[i] != i:
				sum1 += i
				break
		except:
			sum1 += i
			break
	print(sum1)


from collections import Counter

def mex(A):
	A = [-1] + A
	for i in range(1, len(A)):
		if A[i] - A[i - 1] > 1:
			return A[i - 1] + 1
	return A[-1] + 1
for _ in range(int(input())):
	n = input()
	arr = [*map(int, input().split())]
	c = Counter(arr)
	(A, B) = ([], [])
	for i in sorted(c.keys()):
		if c[i] > 1:
			A.append(i)
			B.append(i)
		else:
			A.append(i)
	print(mex(A) + mex(B))


t = int(input())
for j in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	m = max(a)
	s = [0 for i in range(m + 2)]
	s1 = [0 for i in range(m + 2)]
	for i in a:
		if not s[i]:
			s[i] += 1
		else:
			s1[i] += 1
	res = 0
	r = 0
	r1 = 0
	for i in range(len(s)):
		if s[i] == 0 and (not r):
			res += i
			r = 1
		if s1[i] == 0 and (not r1):
			res += i
			r1 = 1
	print(res)


import sys
from math import *
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	i = 0
	while a.count(i) >= 2:
		i += 1
	k1 = i
	while a.count(i) >= 1:
		i += 1
	print(i + k1)


def sort(l):
	for i in range(len(l) - 1):
		for j in range(len(l) - i - 1):
			if l[j] > l[j + 1]:
				(l[j], l[j + 1]) = (l[j + 1], l[j])
	return l

def subset(l):
	l = sort(l)
	l.append(-1)
	A = []
	B = []
	i = 0
	while i < len(l) - 1:
		if l[i] == l[i + 1]:
			A.append(l[i])
			B.append(l[i])
			i = i + 1
		else:
			A.append(l[i])
		i = i + 1
		a = set(A)
		b = set(B)
	return (a, b)

def mex(s):
	s = list(s)
	i = 0
	while i < len(s):
		if s[i] != i:
			return i
		i = i + 1
	return i
case = int(input())
while case:
	n = int(input())
	lst = input().split(' ')
	for i in range(len(lst)):
		lst[i] = int(lst[i])
	(A, B) = subset(lst)
	print(mex(A) + mex(B))
	case = case - 1


from sys import stdin
input = stdin.readline
T = int(input())
for t in range(1, T + 1):
	count = dict()
	for i in range(0, 101):
		count[i] = 0
	n = int(input())
	_input = list(map(int, input().split()))
	for i in _input:
		count[i] += 1
	num1 = 0
	num2 = 0
	for i in range(0, 101):
		if count[i] == 0:
			num1 = i
			break
		count[i] -= 1
	for i in range(0, 101):
		if count[i] == 0:
			num2 = i
			break
	print(num1 + num2)


t = int(input())
for i in range(t):
	counts = [0 for i in range(101)]
	input()
	numbers = [int(i) for i in input().split(' ')]
	for n in numbers:
		counts[n] += 1
	x = 0
	while counts[x] >= 2:
		x += 1
	ans = x
	while counts[x] >= 1:
		x += 1
	ans += x
	print(ans)


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = defaultdict(lambda : 0)
	(a, b) = ([], [])
	(ma, mb) = (0, 0)
	f = 1
	for x in l:
		d[x] += 1
	for i in range(101):
		if d[i] == 0:
			break
		if d[i] == 1:
			ma += 1
			f = 0
		else:
			ma += 1
			if f:
				mb += 1
	print(ma + mb)


import math
import os
import random
import re
import string
from sys import *
from collections import *

def bs(arr, x, l, r):
	if l <= r:
		mid = (r + l) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] > x:
			return bs(arr, x, l, mid - 1)
		else:
			return bs(arr, x, mid + 1, r)
	else:
		return -1

def solve():
	for _ in range(int(input())):
		n = int(input())
		l = list(map(int, stdin.readline().strip().split()))
		l.sort()
		d = dict(Counter(l))
		c = 0
		s = 0
		f = 0
		prev = 1
		for i in sorted(d.keys()):
			if i == c:
				if d[i] >= 2:
					pass
				elif f == 0:
					s += c
					f += 1
			elif f == 1:
				s += c
				f += 1
			else:
				s = 2 * c
				f = 2
			c += 1
			prev = i
			if f == 2:
				break
		if f == 1:
			s += c
		if f == 0:
			s = 2 * c
		print(s)
solve()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	m = {}
	for i in range(101):
		m[i] = 0
	for i in range(n):
		m[l[i]] += 1
	for i in range(101):
		if m[i] == 0:
			ans = i
			break
		m[i] -= 1
	for i in range(n):
		if m[i] == 0:
			ans += i
			break
	print(ans)


def mex(a):
	m = 0
	while True:
		if m in a:
			m += 1
		else:
			return m
t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(i) for i in input().split()]
	a = []
	b = []
	arr = sorted(arr)
	for i in arr:
		if i in a:
			b.append(i)
		else:
			a.append(i)
	print(mex(a) + mex(b))


import sys
sys.setrecursionlimit(10000)
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	mydict = {}
	for i in a:
		if i not in mydict:
			mydict[i] = 0
		mydict[i] += 1
	maxno = 0
	for i in range(102):
		if i not in mydict:
			maxno = i
			break
	ans = maxno
	for i in range(102):
		if not (i in mydict and mydict[i] >= 2):
			ans = i + maxno
			break
	print(ans)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	a = []
	b = []
	f = list(set(l))
	z = min(f)
	f.sort()
	a.append(z)
	i = 0
	while i < len(f):
		l.remove(f[i])
		i += 1
	mini1 = 0
	mini2 = 0
	if l == []:
		mini1 = 0
	else:
		j = 0
		l = list(set(l))
		l.sort()
		for i in range(len(l)):
			if l[i] <= j:
				j += 1
				continue
			else:
				mini1 = j
				break
		mini1 = j
	if f == []:
		mini2 = 0
	else:
		j = 0
		f = list(set(f))
		f.sort()
		for i in range(len(f)):
			if f[i] == j:
				j += 1
				continue
			else:
				mini2 = j
				break
		mini2 = j
	print(mini1 + mini2)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	a = 0
	li = 2
	for j in range(101):
		if l.count(j) > 1:
			continue
		if l.count(j) == 1:
			if li == 1:
				continue
			else:
				a += j
				li = li - 1
				if li == 0:
					break
		if l.count(j) == 0:
			if li == 1:
				a += j
			else:
				a += 2 * j
			break
	print(a)


T = int(input())
for z in range(T):
	n = int(input())
	a = [int(x) for x in input().split()]
	large = max(a)
	a1 = [0 for x in range(large + 2)]
	a2 = [0 for x in range(large + 2)]
	for e in a:
		if a1[e] == 0:
			a1[e] += 1
		else:
			a2[e] += 1
	su = 0
	for i in range(large + 2):
		if a1[i] == 0:
			su += i
			break
	for i in range(large + 2):
		if a2[i] == 0:
			su += i
			break
	print(su)


import sys
t = int(input())
for _ in range(t):
	n = int(sys.stdin.readline())
	arr = list(map(int, sys.stdin.readline().split()))
	arr.sort()
	arrA = []
	arrB = []
	for x in arr:
		if x not in arrA:
			arrA.append(x)
		elif x not in arrB:
			arrB.append(x)
		else:
			continue
	mexA = 0
	mexB = 0
	for i in range(0, 101):
		if i not in arrA:
			mexA = i
			break
	for i in range(0, 101):
		if i not in arrB:
			mexB = i
			break
	print(mexA + mexB)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	A = set()
	B = set()
	for num in arr:
		if not num in A:
			A.add(num)
		elif not num in B:
			B.add(num)
	A = list(A)
	B = list(B)
	A.sort()
	B.sort()
	res = 0
	for (ind, num) in enumerate(A):
		if ind != num:
			res += ind
			break
	else:
		res += len(A)
	for (ind, num) in enumerate(B):
		if ind != num:
			res += ind
			break
	else:
		res += len(B)
	print(res)


from sys import stdin

class Input:

	def __init__(self):
		self.next = self.readline()

	def readline(self):
		return stdin.readline().strip()

	def line(self):
		try:
			return self.next
		finally:
			self.next = self.readline()

	def array(self, sep=' ', cast=int):
		return list(map(cast, self.line().split(sep=sep)))

	def known_tests(self):
		(num_of_cases,) = self.array()
		for case in range(num_of_cases):
			yield self

	def unknown_tests(self):
		while self.next:
			yield self

class Problem:

	def __init__(self, input):
		(n,) = input.array()
		a = input.array()
		a.sort()
		m1 = self.f(a)
		m2 = self.f(a)
		print(m1 + m2)

	def f(self, a):
		r = 0
		for i in range(len(a)):
			if a[i] == None or a[i] < r:
				continue
			if a[i] > r:
				break
			if a[i] == r:
				r += 1
				a[i] = None
		return r
for tc in Input().known_tests():
	Problem(tc)


import math
t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	(A, B) = ([], [])
	prev = a[0]
	cnt = 1
	for i in range(1, n):
		if prev == a[i]:
			cnt += 1
		else:
			if cnt > 0:
				A.append(prev)
			if cnt > 1:
				B.append(prev)
			cnt = 1
			prev = a[i]
	if cnt > 0:
		A.append(prev)
	if cnt > 1:
		B.append(prev)
	(a, b) = (0, 0)
	for x in A:
		if a == x:
			a += 1
		else:
			break
	for x in B:
		if b == x:
			b += 1
		else:
			break
	print(a + b)
	t -= 1


import os
import sys
from io import BytesIO, IOBase

def solution(arr, n):
	arr.sort()
	(s1, s2) = ([], [])
	i = 0
	while i < n:
		s1.append(arr[i])
		while i < n - 1 and arr[i] == arr[i + 1]:
			s2.append(arr[i + 1])
			i += 1
		i += 1
	(res, x) = (0, 0)
	while True:
		if x not in s1:
			res += x
			break
		x += 1
	x = 0
	while True and s2:
		if x not in s2:
			res += x
			break
		x += 1
	write(res)

def main():
	for _ in range(r_int()):
		n = r_int()
		arr = r_array()
		solution(arr, n)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, end='\n'):
	for x in args[:-1]:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(str(args[-1]))
	sys.stdout.write(end)

def r_array():
	return [int(x) for x in input().split()]

def r_int():
	return int(input())
main()


def answer(n, ary):
	sum = 0
	inc = 2
	for i in range(n + 1):
		if ary.count(i) >= 2:
			sum += inc
		elif ary.count(i) == 1:
			inc = 1
			sum += inc
		else:
			return sum

def main():
	t = int(input())
	n = [0] * t
	ary = [0] * t
	for j in range(t):
		n[j] = int(input())
		ary[j] = [int(i) for i in input().split()]
	for j in range(t):
		print(answer(n[j], ary[j]))
main()


def fun(n, arr):
	arr.sort()
	a = arr
	b = []
	i = 0
	while True:
		if i in a:
			ind = arr.index(i)
			b.append(arr.pop(ind))
			i += 1
		else:
			mex_b = i
			break
	j = 0
	while True:
		if j in a:
			j += 1
		else:
			mex_a = j
			break
	print(mex_a + mex_b)
t = int(input())
n = []
num = []
for i in range(t):
	n.append(int(input()))
	tem = list((int(ele) for ele in input().strip().split(' ')))
	num.append(tem)
for i in range(t):
	fun(n[i], num[i])


from collections import defaultdict
t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	x = []
	cnt = 0
	d = defaultdict(lambda : 0)
	for i in a:
		d[i] += 1
	for i in range(max(a) + 2):
		if d[i] > 0:
			d[i] -= 1
		else:
			x.append(i)
			break
	for i in range(max(a) + 2):
		if d[i] == 0:
			x.append(i)
			break
	print(sum(x))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	freq = [0] * 101
	for i in l:
		freq[i] += 1
	ans = 0
	for i in range(len(freq)):
		if freq[i] >= 2:
			continue
		elif freq[i] == 0:
			ans += i
			break
	for i in range(len(freq)):
		if freq[i] <= 1:
			ans += i
			break
	print(ans)


from collections import deque
from collections import Counter
from itertools import islice

def find_missing(nums):
	nums = list(nums)
	nums.sort()
	missing = 0
	for i in range(len(nums)):
		if nums[i] == missing:
			missing += 1
	return missing

def find_mex(arr):
	ctr = Counter(arr)
	arr.sort()
	(seta, setb) = (set(), set())
	for (i, c) in enumerate(arr):
		if ctr[c] >= 2:
			seta.add(c)
			setb.add(c)
		else:
			seta.add(c)
	missing1 = find_missing(seta)
	missing2 = find_missing(setb)
	return missing1 + missing2
t = int(input())
while t > 0:
	n = input()
	arr = list(map(int, input().split()))
	op = find_mex(arr)
	print(op)
	t -= 1


import math
pi = math.acos(-1)
T = int(input())
for _ in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	cnt = [0] * 101
	for x in a:
		cnt[x] = cnt[x] + 1
	ans = 0
	for i in range(0, 101):
		if cnt[i] == 0:
			ans = ans + i
			break
		else:
			cnt[i] = cnt[i] - 1
	for i in range(0, 101):
		if cnt[i] == 0:
			ans = ans + i
			break
	print(ans)


from collections import Counter, defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	inp = list(map(int, input().split()))
	c = Counter(inp)
	c = dict(sorted(c.items(), key=lambda i: i[0]))
	ans = 0
	i = 0
	while 1:
		if i in c:
			if c[i] > 1:
				ans += 1
				i += 1
			else:
				break
		else:
			break
	f = 0
	for j in range(i, len(set(inp))):
		if j not in c:
			ans += j
			f = 1
			break
	if f == 0:
		ans += len(set(inp))
	print(ans)


from collections import Counter
for _ in ' ' * int(input()):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	lst = Counter(a)
	s = 0
	sub = []
	a1 = sorted(set(a))
	f = 0
	f1 = 0
	for i in range(len(a1)):
		if a1[i] != i:
			s += i
			f = 1
			break
		if lst[a1[i]] > 1 and f1 == 0:
			sub.append(a1[i])
		else:
			f1 = 1
	if f == 0:
		s = a1[-1] + 1
	if len(sub) != 0:
		print(s + sub[-1] + 1)
	else:
		print(s)


t = int(input())
while t > 0:
	n = int(input())
	arr = [int(i) for i in input().split()]
	a = []
	b = []
	for i in arr:
		if i not in a:
			a.append(i)
		else:
			b.append(i)
	i = 0
	j = 0
	while i in a:
		i += 1
	while j in b:
		j += 1
	print(i + j)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	A = sorted([int(_) for _ in input().split()])
	S = sorted(list(set(A)))
	D1 = {}
	D2 = {}
	for _ in range(n):
		if A[_] in D1:
			D2[A[_]] = 1
		else:
			D1[A[_]] = 1
	A = sorted(list(D1.keys()))
	B = sorted(list(D2.keys()))
	x = 0
	i = 0
	while i < len(A):
		if i != A[i]:
			break
		i += 1
	x += i
	j = 0
	while j < len(B):
		if j != B[j]:
			break
		j += 1
	x += j
	print(x)


from collections import Counter
z = int(input())
for i in range(z):
	n = int(input())
	a = list(map(int, input().split()))
	c = Counter(a)
	flag1 = False
	for i in range(102):
		if not i in c:
			if flag1:
				b = i
			else:
				a = i
				b = i
			break
		elif c[i] == 1:
			if not flag1:
				a = i
				flag1 = True
	print(a + b)


for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	a1 = 200
	a2 = 200
	for i in range(200, -1, -1):
		if l.count(i) < 2:
			a2 = i
		if l.count(i) < 1:
			a1 = i
	print(a1 + a2)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p) + ': ', end='')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve(case):
	n = int(inp())
	a = lis()
	ans = []
	for i in range(101):
		if len(ans) == 2:
			break
		cnt = a.count(i)
		if cnt > 1:
			continue
		if cnt == 0:
			ans.append(i)
			if len(ans) == 2:
				continue
			ans.append(i)
		else:
			if len(ans) == 1:
				continue
			ans.append(i)
	mx = max(a)
	if len(ans) == 1:
		if a.count(mx) == 1:
			print(ans[0] + mx)
		else:
			print(ans[0] + mx + 1)
	elif len(ans) == 0:
		print(2 * (mx + 1))
	else:
		print(sum(ans))
testcase(int(inp()))


from sys import stdin, stdout

def input():
	a = stdin.readline()
	if a[-1] == '\n':
		a = a[:-1]
	return a

def print(*argv, end='\n', sep=' '):
	n = len(argv)
	for i in range(n):
		if i == n - 1:
			stdout.write(str(argv[i]))
		else:
			stdout.write(str(argv[i]) + sep)
	stdout.write(end)
mod = 10 ** 9 + 7

def lcm(x, y):
	return x * y / gcd(x, y)

def fact(x, mod=mod):
	ans = 1
	for i in range(1, x + 1):
		ans = ans * i % mod
	return ans

def arr2D(n, m, default=0):
	lst = []
	for i in range(n):
		temp = [default] * m
		lst.append(temp)
	return lst

def sortDictV(x):
	return {k: v for (k, v) in sorted(x.items(), key=lambda item: item[1])}

def solve(n, lst):
	cnt = [0] * 101
	for i in lst:
		if cnt[i] == -1:
			cnt[i] = 1
		else:
			cnt[i] += 1
	check = False
	(a, b) = (-1, -1)
	for i in range(101):
		if not check:
			if cnt[i] == 1:
				a = i
				check = True
			elif cnt[i] == 0:
				return i * 2
		elif cnt[i] == 0:
			b = i
			break
	if b == -1:
		return 0
	else:
		return a + b
for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	print(solve(n, lst))


t = int(input())
for _ in range(t):
	u = input()
	nums = list(map(int, input().split()))
	A = [0 for _ in range(101)]
	B = [0 for _ in range(101)]
	for i in nums:
		if A[i] == 0:
			A[i] = 1
		else:
			B[i] = 1
	A_stop = 1000
	B_stop = 1000
	for i in range(101):
		if A_stop == 1000 and A[i] == 0:
			A_stop = i
		if B_stop == 1000 and B[i] == 0:
			B_stop = i
	A_stop = min(A_stop, 100)
	B_stop = min(B_stop, 100)
	print(A_stop + B_stop)


import sys
import math

def scan(input_type='int'):
	return list(map(int, sys.stdin.readline().strip().split()))

def solution():
	for _ in range(int(input())):
		n = int(input())
		a = scan()
		b = {}
		for i in a:
			if i in b:
				b[i] += 1
			else:
				b[i] = 1
		e = max(a)
		c = [0] * (e + 1)
		d = [0] * (e + 1)
		for i in b:
			if b[i] > 1:
				c[i] = 1
				d[i] = 1
				b[i] -= 2
			elif b[i] == 1:
				c[i] = 1
		a = None
		b = None
		for i in range(len(c)):
			if c[i] == 0:
				a = i
				break
		if a is None:
			a = len(c)
		for i in range(len(d)):
			if d[i] == 0:
				b = i
				break
		if b is None:
			b = len(d)
		print(a + b)
solution()


def mex(arr):
	if len(arr) == 0:
		return 0
	for i in range(max(arr) + 2):
		if i not in arr:
			res = i
			return res
for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	a = []
	b = []
	i = 0
	while i < len(arr) - 1:
		if arr[i + 1] == arr[i]:
			a.append(arr[i])
			b.append(arr[i + 1])
			i += 2
		else:
			a.append(arr[i])
			i += 1
	a.append(arr[len(arr) - 1])
	print(mex(a) + mex(b))


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	i = j = 0
	count = [0] * (arr[-1] + 1)
	notPresent = []
	while True:
		if arr[j] == i:
			count[i] += 1
			j += 1
		elif count[i] > 0:
			i += 1
			continue
		else:
			notPresent.append(i)
			i += 1
		if j >= len(arr):
			break
	if not notPresent:
		try:
			i = count.index(1)
			ans = max(arr[-1] + 1, i + arr[-1] + 1)
		except Exception:
			ans = max(arr[-1] + 1, (arr[-1] + 1) * 2)
	else:
		ans = notPresent[0]
		try:
			i = count.index(1)
			if i < ans:
				ans += i
			else:
				ans += ans
		except Exception:
			ans += ans
	print(ans)


from collections import defaultdict
T = int(input().strip())
while T:
	T -= 1
	fq = defaultdict(int)
	n = int(input())
	lis = map(int, input().strip().split())
	maxn = -1
	for num in lis:
		maxn = max(num, maxn)
		fq[num] += 1
	ans = 0
	for num in range(maxn + 2):
		if fq[num] < 2:
			ans = num
			break
	for num in range(ans, maxn + 2):
		if fq[num] < 1:
			ans += num
			break
	print(ans)


import math

def solve():
	n = int(input())
	arr = [int(x) for x in input().split()]
	A = []
	B = []
	ma = 0
	mb = 0
	arr.sort()
	for x in arr:
		if x == ma:
			A.append(x)
			ma += 1
		else:
			B.append(x)
			if x == mb:
				mb += 1
	print(ma + mb)
	return

def main():
	t = int(input())
	for i in range(t):
		solve()
	return
main()


from sys import stdin
inp = lambda : stdin.readline().strip()
t = int(inp())
for _ in range(t):
	n = int(inp())
	a = [int(x) for x in inp().split()]
	cnt = [0] * 101
	for i in a:
		cnt[i] += 1
	ans = 0
	flag = True
	for i in range(101):
		if cnt[i] > 1 and flag:
			ans += 1
		elif cnt[i] == 0:
			ans += i
			break
		else:
			flag = False
	print(ans)


import sys
for i in range(0, int(sys.stdin.readline())):
	leng = sys.stdin.readline()
	vllist = list(map(int, sys.stdin.readline().split()))
	c = 0
	while c in vllist:
		vllist.pop(vllist.index(c))
		c += 1
	mexa = c
	c = 0
	while c in vllist:
		vllist.pop(vllist.index(c))
		c += 1
	mexb = c
	sys.stdout.write(str(mexa + mexb))
	sys.stdout.write('\n')


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		d = {}
		for j in a:
			if j not in d:
				d[j] = 1
			else:
				d[j] += 1
		mexa = mexb = -1
		for i in range(102):
			if i not in d:
				if mexa == -1:
					mexa = mexb = i
				else:
					mexb = i
			elif d[i] >= 2:
				continue
			elif d[i] == 1:
				if mexa == -1:
					mexa = i
			if mexa != -1 and mexb != -1:
				break
		print(mexa + mexb)
main()


t = int(input())
while t != 0:
	case = []
	t -= 1
	n = int(input())
	result = 0
	temp = input().split(' ')
	for i in range(0, n):
		case.append(int(temp[i]))
	for i in range(0, 101):
		if i in case:
			case.remove(i)
		else:
			result += i
			break
	for i in range(0, 101):
		if i in case:
			case.remove(i)
		else:
			result += i
			break
	print(result)


from collections import Counter
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	(a1, a2) = (None, None)
	freq = Counter(a)
	for i in range(0, 101):
		if freq.get(i, 0) == 0:
			if a1 == None and a2 == None:
				print(2 * i)
			else:
				print(a1 + i)
			break
		elif freq.get(i) == 1:
			if a1 == None:
				a1 = i


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	co = Counter(a)
	b = []
	c = []
	b1 = -1
	c1 = -1
	for i in range(101):
		if i in co:
			if co[i] == 1:
				b.append(i)
			else:
				b.append(i)
				c.append(i)
	if len(b) == 0:
		b1 = 0
	else:
		for i in range(len(b)):
			if i != b[i]:
				b1 = i
				break
	if len(c) == 0:
		c1 = 0
	else:
		for i in range(len(c)):
			if i != c[i]:
				c1 = i
				break
	if b1 == -1:
		b1 = max(b) + 1
	if c1 == -1:
		c1 = max(c) + 1
	print(b1 + c1)


import math
import sys
import collections
import bisect
import time

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
for t in range(int(input())):
	n = int(input())
	arr = get_list()
	arr.sort()
	ans1 = set()
	ans2 = set()
	for i in range(n):
		ele = arr[i]
		if ele not in ans1:
			ans1.add(ele)
		else:
			ans2.add(ele)
	val = 0
	for i in range(101):
		if i not in ans1:
			val += i
			break
	for i in range(101):
		if i not in ans2:
			val += i
			break
	print(val)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	i = 0
	while True:
		if a.count(i) >= 2:
			i += 1
		else:
			break
	j = i
	while True:
		if j in a:
			j += 1
		else:
			break
	print(i + j)


import collections

def solution(n, a):
	c = collections.Counter(a)
	i = 0
	x = -1
	while True:
		if c[i] == 1 and x < 0:
			x = i
		elif c[i] == 0:
			if x < 0:
				return 2 * i
			else:
				return x + i
		i += 1
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	print(solution(n, a))


def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
import collections as c

def solve():
	N = getInt()
	A = getInts()
	counts = c.defaultdict(int)
	for a in A:
		counts[a] += 1
	j = 0
	ans = []
	while True:
		if len(ans) == 0:
			if counts[j] == 0:
				ans.append(j)
				if len(ans) == 2:
					break
				ans.append(j)
				break
			elif counts[j] == 1:
				ans.append(j)
				if len(ans) == 2:
					break
		elif counts[j] == 0:
			ans.append(j)
			break
		j += 1
	return sum(ans)
T = getInt()
for t in range(T):
	ans = solve()
	print(ans)


from sys import stdin, stdout
import math, sys, heapq
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
from os import path
import random
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def I():
		return int(input())

	def In():
		return map(int, input().split())
else:

	def I():
		return int(stdin.readline())

	def In():
		return map(int, stdin.readline().split())

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return -1

def main():
	try:
		n = I()
		l = list(In())
		(a, b) = (-1, -1)
		d = dict(l)
		(a, b) = ([], [])
		for x in d:
			if d[x] >= 2:
				a.append(x)
				b.append(x)
			else:
				a.append(x)
		a.sort()
		b.sort()
		(A, B) = (-1, -1)
		if len(a) > 0:
			for x in range(a[-1] + 1):
				if a[x] != x:
					A = x
					break
			if A == -1:
				A = a[-1] + 1
		if len(b) > 0:
			for x in range(b[-1] + 1):
				if b[x] != x:
					B = x
					break
			if B == -1:
				B = b[-1] + 1
		if A == -1:
			A = 0
		if B == -1:
			B = 0
		print(A + B)
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(I()):
	main()


def findMax(l):
	l = sorted(set(l))
	for i in range(len(l) + 1):
		if i >= len(l):
			return i
		if i != l[i]:
			return i
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in l:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	a = []
	b = []
	for i in range(0, 101):
		if i in d:
			a.append(i)
			d[i] -= 1
			if d[i] != 0:
				b.append(i)
	print(findMax(a) + findMax(b))


from collections import defaultdict
tt = int(input())
while tt != 0:
	n = int(input())
	d = defaultdict(int)
	list1 = list(map(int, input().split()))
	maxi = 0
	for i in range(n):
		d[list1[i]] += 1
		maxi = max(maxi, list1[i])
	ans = 0
	t = -1
	for i in range(maxi + 2):
		if i not in d.keys():
			ans += i
			t = i
			break
	for i in range(t + 1):
		if i == t:
			ans += i
		if d[i] == 1:
			ans += i
			break
	print(ans)
	tt -= 1


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().strip().split()))
	cnt_t = [0] * 101
	for x in a:
		cnt_t[x] += 1
	mex_comp = None
	for (i, count) in enumerate(cnt_t):
		if count == 0:
			mex_comp = i
			break
	assert mex_comp != None
	for (i, count) in enumerate(cnt_t):
		if count != 0:
			cnt_t[i] -= 1
	mex_a = mex_comp
	mex_b = None
	for (i, count) in enumerate(cnt_t):
		if count == 0:
			mex_b = i
			break
	assert mex_b != None
	print(mex_b + mex_a)


import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import copy
import decimal

class Scanner:

	@staticmethod
	def int():
		return int(sys.stdin.readline().rstrip())

	@staticmethod
	def string():
		return sys.stdin.readline().rstrip()

	@staticmethod
	def map_int():
		return [int(x) for x in Scanner.string().split()]

	@staticmethod
	def string_list(n):
		return [Scanner.string() for i in range(n)]

	@staticmethod
	def int_list_list(n):
		return [Scanner.map_int() for i in range(n)]

	@staticmethod
	def int_cols_list(n):
		return [Scanner.int() for i in range(n)]

def solve():
	n = Scanner.int()
	a = Scanner.map_int()
	a.sort()
	A = []
	B = []
	for i in range(0, n):
		if len(A) == 0:
			A.append(a[i])
		elif A[-1] == a[i]:
			B.append(a[i])
		else:
			A.append(a[i])

	def mex(a):
		a.sort()
		s = set()
		for i in a:
			s.add(i)
		for i in range(0, 101):
			if not i in s:
				return i
		return 100
	print(mex(A) + mex(B))

def main():
	T = Scanner.int()
	for _ in range(T):
		solve()
main()


from sys import stdin, stdout

def mex(ar):
	n = len(ar)
	have = [False] * (n + 1)
	for item in ar:
		if item <= n:
			have[item] = True
	return have.index(False)
t = int(stdin.readline())
for case in range(t):
	n = int(stdin.readline())
	xx = list(map(int, stdin.readline().split()))
	count = [0] * 101
	for item in xx:
		count[item] += 1
	mex_a = mex(xx)
	b = []
	for i in range(101):
		if count[i] >= 2:
			b.append(i)
	stdout.write('{}\n'.format(mex_a + mex(b)))


from os import path
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input().rstrip()

def mi():
	return map(int, input().split())

def li():
	return list(mi())

def ceil(a, b):
	return (a + b - 1) // b
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('a')
test = 0

def solve():
	for _ in range(ii()):
		n = ii()
		a = li()
		m = dd(int)
		for i in a:
			m[i] += 1
		ans = 0
		for i in range(101):
			if i not in m or m[i] == 1:
				ans += i
				break
		for i in range(101):
			if i not in m:
				ans += i
				break
		print(ans)
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = sys.stdin.readline
t = 1
if test:
	t = ii()
for _ in range(t):
	solve()


cases = int(input())
for _ in range(cases):
	count = 0
	a = []
	n = int(input())
	b = list(map(int, input().split()))
	b.sort()
	s = set(b)
	s = list(s)
	s.sort()
	a.append(s[0])
	b.remove(s[0])
	for x in range(len(s) - 1):
		if s[x] == s[x + 1] - 1:
			a.append(s[x + 1])
			b.remove(s[x + 1])
		else:
			break
	for x in range(101):
		if x not in a:
			count += x
			break
	for x in range(101):
		if x not in b:
			count += x
			break
	print(count)


t = int(input())
for case in range(t):
	n = int(input())
	a = [int(s) for s in input().split(' ')]
	ans = 0
	for i in range(n + 1):
		if a.count(i) < 2:
			ans += i
			break
	for i in range(n + 1):
		if a.count(i) < 1:
			ans += i
			break
	print(ans)


[(lambda N, n, d: ([d.__setitem__(i, d.get(i, 0) + 1) for i in n], print(min((lambda n: n if n else [0])([i for i in range(101) if i not in d])) + min((lambda n: n if n else [0])([i for i in range(101) if d.get(i, 0) <= 1])))))(int(input()), list(map(int, input().split())), {}) for t in range(int(input()))]


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	x = set()
	y = set()
	for i in a:
		if i not in x:
			x.add(i)
		else:
			y.add(i)
	x = list(x)
	x.sort()
	y = list(y)
	y.sort()
	ans = []
	for i in range(101):
		if i == len(x):
			break
		if x[i] != i:
			ans.append(i)
			break
	if len(ans) == 0:
		ans.append(x[-1] + 1)
	if len(y) == 0:
		ans.append(0)
	else:
		for i in range(101):
			if i == len(y):
				break
			if y[i] != i:
				ans.append(i)
				break
		if len(ans) == 1:
			ans.append(y[-1] + 1)
	print(sum(ans))


t = int(input())
while t:
	n = int(input())
	li = list(map(int, input().split()))
	(a, b) = ([], [])
	(small_a, small_b) = (0, 0)
	for i in li:
		if i not in a:
			a.append(i)
		else:
			b.append(i)
	for i in range(0, 101):
		if i not in a:
			small_a = i
			break
	for i in range(0, 101):
		if i not in b:
			small_b = i
			break
	print(small_a + small_b)
	t -= 1


from itertools import count, filterfalse
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	a = []
	b = []
	for i in arr:
		if i not in a:
			a.append(i)
		else:
			b.append(i)
	mexa = next(filterfalse(set(a).__contains__, count(0)))
	mexb = next(filterfalse(set(b).__contains__, count(0)))
	print(mexa + mexb)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	frq = [0] * (2 * n)
	for c in l:
		frq[c] += 1
	wan = False
	ans = 0
	for i in range(2 * n):
		if frq[i] == 0:
			if wan == False:
				ans += 2 * i
				break
			else:
				ans += i
				break
		if frq[i] == 1:
			if wan == False:
				ans += i
				wan = True
	print(ans)


for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	d = {}
	for i in ar:
		try:
			d[i] += 1
		except:
			d[i] = 1
	cnt = 0
	s = 0
	t1 = []
	t2 = []
	for i in d:
		if d[i] > 1:
			t1.append(i)
			t2.append(i)
		else:
			t2.append(i)
	t1.sort()
	t2.sort()
	flag = 0
	for i in range(len(t1)):
		if t1[i] != i:
			s += i
			flag = 1
			break
	if flag == 0:
		s += len(t1)
	flag = 0
	for i in range(len(t2)):
		if t2[i] != i:
			s += i
			flag = 1
			break
	if flag == 0:
		s += len(t2)
	print(s)


def mex(arr):
	if arr == []:
		return 0
	arr.sort()
	res = None
	for i in range(len(arr)):
		if arr[i] != i:
			res = i
			break
	if res == None:
		res = len(arr)
	return res
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	a = []
	b = []
	dic = {}
	for i in arr:
		if i not in dic:
			dic[i] = 1
		else:
			dic[i] += 1
	for i in dic:
		if dic[i] > 1:
			a.append(i)
			b.append(i)
			dic[i] = 0
		else:
			a.append(i)
			dic[i] = 0
	x = mex(a)
	y = mex(b)
	print(x + y)


t = int(input())
while t:
	t = t - 1
	n = int(input())
	l = [int(x) for x in input().split()]
	l.sort()
	su = 0
	dic = {}
	df = max(l)
	for i in range(df + 1):
		dic[i] = 0
	for i in range(n):
		dic[l[i]] += 1
	b = list(set(l))
	act = 0
	for i in range(df + 1):
		if dic[i] == 0:
			su = su + i
			act = 1
			break
	if act == 0:
		su = df + 1
	act = 0
	for i in range(df + 1):
		if dic[i] == 1 or dic[i] == 0:
			su = su + i
			act = 1
			break
	if act == 0:
		su = su + df + 1
	print(su)


for _ in range(int(input())):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	d = {}
	for i in l:
		d[i] = d.get(i, 0) + 1
	a = 0
	b = 0
	(flag1, flag2) = (1, 1)
	while flag1 or flag2:
		if a not in d:
			break
		else:
			a += 1
		if flag2:
			if b not in d or (b <= a and d[b] == 1):
				flag2 = 0
			else:
				b += 1
	print(a + b)


import sys
from sys import stdout
import random
from fractions import Fraction
from math import *

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def finput():
	return float(input())

def tinput():
	return input().split()

def linput():
	return list(input())

def rinput():
	return map(int, tinput())

def fiinput():
	return map(float, tinput())

def rlinput():
	return list(map(int, input().split()))

def trinput():
	return tuple(rinput())

def srlinput():
	return sorted(list(map(int, input().split())))

def NOYES(fl):
	if fl:
		print('NO')
	else:
		print('YES')

def YESNO(fl):
	if fl:
		print('YES')
	else:
		print('NO')

def main():
	n = iinput()
	q = srlinput()
	w = set([i for i in range(105)])
	res = list(w - set(q))[0]
	for i in range(res):
		del q[q.index(i)]
	print(list(w - set(q))[0] + res)
for i in range(iinput()):
	main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	cnt = [0] * 102
	for i in a:
		cnt[i] += 1
	ind1 = 0
	ind2 = 0
	flag = 2
	for i in range(101):
		if cnt[i] <= 1 and flag == 2:
			ind2 = i
			flag -= 1
		if cnt[i] == 0 and flag == 1:
			ind1 = i
			flag = 0
	print(ind1 + ind2)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	(a, b) = (None, None)
	d = {}
	for i in range(101):
		d[i] = 0
	for i in l:
		d[i] = d[i] + 1
	for i in range(101):
		if d[i] < 2:
			if d[i] == 1:
				if a == None:
					a = i
			if d[i] == 0:
				if a == None:
					(a, b) = (i, i)
				else:
					b = i
		if a != None and b != None:
			break
	print(a + b)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	cnt = [0] * 101
	for i in range(len(a)):
		cnt[a[i]] += 1
	ans = 0
	for i in range(101):
		if cnt[i] == 0:
			ans += i
			break
	for i in range(101):
		if cnt[i] <= 1:
			ans += i
			break
	print(ans)


for i in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	p = 0
	r = -1
	q = 1
	an = 0
	flag = -1
	a.sort()
	for j in set(a):
		if j != p:
			if q == 1:
				an = 2 * p
				flag = 1
				break
			else:
				an += p
				flag = 1
				break
		else:
			x = a.count(j)
			if x == 1:
				if q == 1:
					an += j
					q = -1
					flag = 0
		p += 1
	if flag == 0:
		print(an + len(set(a)))
	elif flag == 1:
		print(an)
	else:
		print(2 * len(set(a)))


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	s1 = set()
	s2 = set()
	for i in a:
		if i not in s1:
			s1.add(i)
		elif i not in s2:
			s2.add(i)
	c = 0
	for i in s1:
		if i != c:
			break
		else:
			c += 1
	c2 = 0
	for i in s2:
		if i != c2:
			break
		else:
			c2 += 1
	print(c + c2)


t = int(input())
for z in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	max_index = max(l) + 1
	freq = [0] * 102
	for i in l:
		freq[i] += 1
	first = 0
	while freq[first] > 1:
		first += 1
	sec = first
	while freq[sec] > 0:
		sec += 1
	print(sec + first)


from collections import defaultdict as dc

def solv():
	x = int(input())
	s = list(map(int, input().split()))
	s.sort()
	a = dc(lambda : 0)
	b = dc(lambda : 0)
	for n in s:
		if a[n] == 0:
			a[n] = 1
		else:
			b[n] = 1
	p = 0
	while a[p]:
		p += 1
	q = 0
	while b[q]:
		q += 1
	print(p + q)
for n in range(int(input())):
	solv()


import sys
input = sys.stdin.readline
import sys
import heapq
import copy
import math
import decimal

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def insr2():
	s = input()
	s = list(s[:len(s) - 1])
	s = [ord(s[i]) - ord('a') for i in range(len(s))]
	return s

def invr():
	return map(int, input().split())
ans = 0

def pr_list(a):
	print(*a, sep=' ')

def swap(a, b):
	temp = a
	a = b
	b = temp
	return [a, b]

def pri(a, b):
	s = '? ' + str(a) + ' ' + str(b)
	print(s)
	sys.stdout.flush()

def main():
	tests = inp()
	mod = 1000000007
	limit = 10 ** 18
	ans = 0
	stack = []
	hashm = {}
	arr = []
	heapq.heapify(arr)

	def find_next(hashm, itr):
		for i in range(itr, len(hashm)):
			if hashm[i] == 0:
				return i
	for test in range(tests):
		n = inp()
		arr = inlt()
		hashm = [0 for i in range(103)]
		for i in arr:
			hashm[i] = hashm[i] + 1
		ans = 0
		found = 0
		for i in range(101):
			if hashm[i] == 0:
				if found == 1:
					ans = ans + i
					found = 2
					break
				else:
					found = 2
					ans = ans + 2 * i
					break
			elif hashm[i] == 1:
				if found == 1:
					found = 2
					ans = ans + i
					break
				elif found == 0:
					found = 1
					ans = ans + i
					ans = ans + find_next(hashm, i + 1)
					break
		print(ans)
main()


def ans(A):
	d = {}
	for i in A:
		d[i] = d.get(i, 0) + 1
	ans = 0
	for i in range(105):
		if i not in d:
			ans += i
			break
		else:
			d[i] -= 1
			if d[i] == 0:
				del d[i]
	for i in range(105):
		if i not in d:
			ans += i
			break
		else:
			d[i] -= 1
			if d[i] == 0:
				del d[i]
	return ans
T = int(input())
for i in range(T):
	n = int(input())
	arr = list(map(int, input().strip().split(' ')))
	print(ans(arr))


from sys import *
from math import *
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	a.sort()
	x = [a[0]]
	j = []
	if x[0] != 0:
		m1 = 0
	else:
		j = [0]
		k = 0
		for i in range(1, n):
			if x[k] + 1 == a[i]:
				x.append(a[i])
				j.append(i)
				k += 1
		m1 = max(x) + 1
	y = []
	for i in range(n):
		if i not in j:
			y.append(a[i])
	if len(y) == 0:
		m2 = 0
	else:
		y.sort()
		if y[0] != 0:
			m2 = 0
		else:
			f = 0
			for i in range(len(y)):
				if y[i] + 1 not in y:
					m2 = y[i] + 1
					f = 1
					break
			if f == 0:
				m2 = max(y) + 1
	print(m1 + m2)


t = int(input())
for i in range(t):
	n = int(input())
	a = 0
	b = 0
	l = list(map(int, input().split()))
	freq = []
	for i in range(101):
		freq.append(0)
	for i in range(len(l)):
		freq[l[i]] += 1
	for i in range(101):
		if freq[i] == 0:
			a += i
			break
	for i in range(101):
		if freq[i] <= 1:
			b += i
			break
	print(a + b)


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	m1 = m2 = 0
	m11 = m22 = True
	for x in range(0, n + 2):
		if a.count(x) == 0 and m11:
			m1 = x
			m11 = False
		if a.count(x) == 0 and m22:
			m2 = x
			m22 = False
		if a.count(x) == 1 and m11:
			m1 = x
			m11 = False
			continue
	print(m1 + m2)
	t -= 1


t = int(input())
for h in range(t):
	n = int(input())
	x = list(map(int, input().split()))
	if 0 not in x:
		ans = 0
	else:
		mx = max(x)
		s = list(set(range(mx + 2)))
		x.sort()
		y = []
		z = []
		for i in x:
			if i not in y:
				y.append(i)
			else:
				z.append(i)
		my = []
		mz = []
		for i in s:
			if i not in y:
				my.append(i)
			if i not in z:
				mz.append(i)
		ans = min(my) + min(mz)
	print(ans)


from collections import Counter
for _ in range(int(input())):
	N = int(input())
	List = [int(x) for x in input().split()]
	Dict = Counter(List)
	first = 0
	for i in range(101):
		if Dict[i]:
			Dict[i] -= 1
		else:
			first = i
			break
	second = 0
	for i in range(101):
		if Dict[i]:
			Dict[i] -= 1
		else:
			second = i
			break
	print(first + second)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	b = 0
	d = 0
	for k in a:
		if b == k:
			b += 1
		elif d == k:
			d += 1
	print(b + d)


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
from collections import defaultdict

def gift():
	for _ in range(t):
		n = int(input())
		array = list(map(int, input().split()))
		array.sort()
		dic = defaultdict(lambda : 0)
		for ele in array:
			dic[ele] += 1
		counter = 0
		ans = 0
		for i in range(102):
			if counter == 0:
				if dic[i] == 1:
					ans += i
					counter += 1
				elif dic[i] == 0:
					ans += 2 * i
					counter += 2
			elif counter == 1:
				if dic[i] == 0:
					ans += i
					break
			else:
				break
		yield ans
t = int(input())
ans = gift()
print(*ans, sep='\n')


import os
import sys
from io import BytesIO, IOBase
from collections import Counter

def find_mex(a):
	Mex = 0
	while Mex in a:
		Mex += 1
	return Mex

def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		b = sorted(list(set(a)))
		c = Counter(a)
		p = []
		q = []
		for (key, val) in c.items():
			if val > 1:
				p.append(key)
				q.append(key)
			else:
				p.append(key)
		ans = find_mex(set(p)) + find_mex(set(q))
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	n = int(input())
	frequency = [0] * 101
	for item in list(map(int, input().split())):
		frequency[item] += 1
	ans = 0
	for i in range(101):
		if frequency[i] == 0:
			ans += i
			break
		frequency[i] -= 1
	for i in range(101):
		if frequency[i] == 0:
			ans += i
			break
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	count = [0] * 200
	for v in map(int, input().split()):
		count[v] += 1
	out = 0
	curr = 2
	for v in count:
		curr = min(curr, v)
		out += curr
	print(out)


def solution(A):
	m = max(A)
	if m < 1:
		return 1
	if len(A) == 1:
		return 2 if A[0] == 1 else 1
	l = [0] * m
	for i in range(len(A)):
		if A[i] > 0:
			if l[A[i] - 1] != 1:
				l[A[i] - 1] = 1
	for i in range(len(l)):
		if l[i] == 0:
			return i + 1
	return i + 2
a = int(input())
for i in range(a):
	b = int(input())
	x1 = []
	x2 = []
	c = [int(x) for x in input().split()]
	d = [0] * 101
	for j in range(b):
		d[c[j]] = d[c[j]] + 1
	for j in range(101):
		if d[j] >= 2:
			x1.append(j)
			x2.append(j)
		if d[j] == 1:
			x1.append(j)
	if x1 == []:
		a1 = 0
	elif min(x1) > 0:
		a1 = 0
	else:
		a1 = solution(x1)
	if x2 == []:
		a2 = 0
	elif min(x2) > 0:
		a2 = 0
	else:
		a2 = solution(x2)
	print(a1 + a2)


from collections import Counter
try:
	test = int(input())
	for _ in range(test):
		num = int(input())
		arr = list(map(int, input().strip().split()))[:num]
		A = []
		B = []
		count = dict(Counter(arr))
		for i in count:
			if count[i] % 2 == 0:
				val = count[i] // 2
				for k in range(0, val):
					A.append(i)
					B.append(i)
			else:
				A.append(i)
				for k in range(0, count[i] - 1):
					B.append(i)
		valA = 0
		valB = 0
		if len(A) != 0:
			for i in range(0, max(A) + 2):
				if i not in A:
					valA = i
					break
		if len(B) != 0:
			for i in range(0, max(B) + 2):
				if i not in B:
					valB = i
					break
		print(valA + valB)
except:
	pass


t = int(input())
for _ in range(t):
	n = int(input())
	(*a,) = map(int, input().split())
	a.sort()
	(b1, b2) = ([], [])
	for (i, x) in enumerate(a):
		if x not in b1:
			b1.append(x)
		else:
			b2.append(x)
	ans = 0
	for i in range(0, 101):
		if i not in b1:
			ans += i
			break
	for i in range(0, 101):
		if i not in b2:
			ans += i
			break
	print(ans)


from fractions import Fraction
from collections import defaultdict
import math
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
t = int(input())
for _ in range(t):
	n = int(input())
	l = list([int(x) for x in input().split()])
	mx = max(l)
	l1 = []
	l2 = []
	for i in range(mx + 1):
		c = 0
		for j in l:
			if i == j:
				c += 1
		if c == 1:
			l1.append(i)
		if c >= 2:
			l1.append(i)
			l2.append(i)
	m1 = max(l1)
	s1 = -1
	s = 0
	for i in range(m1 + 1):
		if i not in l1:
			s1 = i
			break
	s2 = -1
	if len(l2) > 0:
		m2 = max(l2)
		for i in range(m2 + 1):
			if i not in l2:
				s2 = i
				break
	else:
		s2 = 0
	if s1 == -1:
		s1 = m1 + 1
	if s2 == -1:
		s2 = m2 + 1
	s = s1 + s2
	print(s)


t = int(input())
i = 0
while i < t:
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	k = [a[0]]
	h = []
	j = 0
	v = 0
	while j < n:
		if a.count(j) == 0:
			break
		j += 1
	while v < j:
		if a.count(v) <= 1:
			break
		v += 1
	print(j + v)
	i += 1


a = int(input())
e = []

def cont(no, arr):
	arr = list(set(arr))
	for i in range(len(arr)):
		if no == arr[i]:
			return True
for i in range(a):
	b = int(input())
	c = list(map(int, input().split()))
	e.append(c)
for i in range(len(e)):
	e[i].sort()
for i in e:
	f = []
	g = []
	for j in range(len(i)):
		if cont(i[j], f):
			g.append(i[j])
		else:
			f.append(i[j])
	no1 = 0
	no2 = 0
	for i in range(101):
		if cont(i, f):
			no1 = i + 1
		else:
			break
	for i in range(101):
		if cont(i, g):
			no2 = i + 1
		else:
			break
	print(no1 + no2)


import collections
t = input()
t = int(t)

def solve(n, arr):
	arr_dict = collections.Counter(arr)
	mex_A = 0
	mex_B = 0
	flag = 0
	for i in range(101):
		if i not in arr_dict:
			break
		if arr_dict[i] >= 2 and flag == 0:
			mex_A = i + 1
			mex_B = i + 1
		elif arr_dict[i] == 1 and flag == 0:
			mex_A = i + 1
			flag = 1
		else:
			mex_A = i + 1
	print(mex_A + mex_B)
for i in range(t):
	n = input()
	n = int(n)
	arr = list(map(int, input().split()))
	solve(n, arr)


t = int(input())
for ttt in range(t):
	n = int(input())
	f = list(map(int, input().split()))
	d = {}
	max = 0
	for i in range(len(f)):
		if f[i] not in d.keys():
			d[f[i]] = 0
		d[f[i]] += 1
		if f[i] > max:
			max = f[i]
	k = 0
	q = 0
	for i in range(max + 2):
		if i not in d.keys() or d[i] == 0:
			k += i * (2 - q)
			break
		elif d[i] == 1:
			if q == 0:
				k += i
				q += 1
	print(k)


from sys import stdin, stdout

def main():
	t = int(stdin.readline())
	for _ in range(t):
		n = int(stdin.readline())
		S = [int(i) for i in stdin.readline().split()]
		S.sort()
		a_mex = 0
		b_mex = 0
		a_adding = True
		b_adding = True
		for k in S:
			if k == a_mex:
				a_mex += 1
				continue
			if k == b_mex:
				b_mex += 1
		print(a_mex + b_mex)
main()


for x in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l = sorted(l)
	a = 0
	b = 0
	while l.count(a) > 1:
		a += 1
		b += 1
	while l.count(b) > 0:
		b += 1
	print(a + b)


n = int(input())
while n > 0:
	n -= 1
	te = int(input())
	a = [int(x) for x in input().split(' ')]
	d = {}
	for i in range(len(a)):
		if a[i] in d:
			d[a[i]] += 1
		else:
			d[a[i]] = 1
	ans = 0
	f = 0
	for i in range(len(a)):
		if f == 0:
			if i not in d:
				ans += 2 * i
				break
			elif d[i] == 1:
				ans += i
				f = 1
		elif f == 1:
			if i not in d:
				ans += i
				f -= 1
				break
	if f == 2:
		ans = (max(a) + 1) * 2
	elif f == 1:
		ans += max(a) + 1
	print(ans)


import sys
from collections import Counter

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 19
MOD = 10 ** 9 + 7
for _ in range(INT()):
	N = INT()
	A = LIST()
	C = Counter(A)
	has2 = True
	ans = 0
	for i in range(101):
		if C[i] >= 2 and has2:
			ans += 2
		elif C[i] >= 1:
			has2 = False
			ans += 1
		else:
			break
	print(ans)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	s1 = set()
	s2 = set()
	for i in arr:
		if i not in s1:
			s1.add(i)
		else:
			s2.add(i)
	c = ans = 0
	for i in s1:
		if i != c:
			break
		else:
			c += 1
	ans += c
	c = 0
	for i in s2:
		if i != c:
			break
		else:
			c += 1
	ans += c
	print(ans)


def mex(L):
	M = [False] * 101
	for i in range(0, len(L)):
		M[L[i]] = True
	for i in range(0, len(M)):
		if not M[i]:
			return i
t = int(input())
for i in range(0, t):
	n = int(input())
	L = list(map(int, input().split()))
	L.sort()
	count = 0
	for i in range(0, n):
		if L[i] == 0:
			count += 1
	if count == 0:
		print(0)
	elif count == 1:
		print(mex(L))
	else:
		M = [0]
		N = []
		for i in range(1, n):
			if L[i] == L[i - 1] + 1:
				if M[-1] == L[i - 1]:
					M.append(L[i])
				else:
					N.append(L[i])
			elif M[-1] == L[i - 1]:
				N.append(L[i])
			else:
				M.append(L[i])
		print(mex(M) + mex(N))


T = int(input())
for _ in range(0, T):
	n = int(input())
	s = [int(x) for x in input().split()]
	pos = [0] * 101
	for i in range(0, len(s)):
		pos[s[i]] += 1
	ans = 0
	flag = 0
	for i in range(0, 101):
		if flag == 0 and pos[i] == 1:
			flag = 1
			ans += i
		elif flag == 0 and pos[i] == 0:
			ans += i
			ans += i
			break
		elif flag == 1 and pos[i] == 0:
			ans += i
			break
	print(ans)


def ans(n, arr):
	d = dict()
	for i in range(n):
		d[arr[i]] = d.get(arr[i], 0) + 1
	flag = 0
	(a, b) = (0, 0)
	for i in range(n):
		x = d.get(i, 0)
		if x >= 2:
			a += 1
			if flag == 0:
				b += 1
		elif x == 1:
			a += 1
			flag = 1
		elif x == 0:
			break
	return a + b
t = int(input())
L = []
for i in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	L.append(ans(n, arr))
for l in L:
	print(l)


def solve(a):
	(x, y) = (-1, -1)
	for i in range(101):
		if a.count(i) == 0:
			return 2 * i if x == -1 else x + i
		elif a.count(i) == 1:
			if x == -1:
				x = i
	return 101 + x if x != -1 else 101 + 102
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	a.sort()
	print(solve(a))


import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
from itertools import accumulate

def Int():
	return int(sys.stdin.readline())

def Mint():
	return map(int, sys.stdin.readline().split())

def Lstr():
	return list(sys.stdin.readline().strip())

def Str():
	return sys.stdin.readline().strip()

def Mstr():
	return map(str, sys.stdin.readline().strip().split())

def List():
	return list(map(int, sys.stdin.readline().split()))

def Hash():
	return dict()

def Mod():
	return 1000000007

def Ncr(n, r, p):
	return fact[n] * (ifact[r] * ifact[n - r] % p) % p

def Most_frequent(list):
	return max(set(list), key=list.count)

def Mat2x2(n):
	return [List() for _ in range(n)]

def Lcm(x, y):
	return x * y // gcd(x, y)

def dtob(n):
	return bin(n).replace('0b', '')

def btod(n):
	return int(n, 2)

def common(l1, l2):
	return set(l1).intersection(l2)

def solution():
	for i in range(Int()):
		n = Int()
		a = List()
		o = [0] * 101
		p = [0] * 101
		for i in a:
			if o[i] > 0:
				p[i] += 1
			else:
				o[i] += 1
		print(o.index(0) + p.index(0))
solution()


def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
n = inp()
for _ in range(n):
	m = inp()
	l = inlt()
	val = [0] * 102
	for x in l:
		val[x] += 1
	ans = 0
	cnt = 0
	for i in range(102):
		if val[i] == 0 and cnt == 0:
			ans = 2 * i
			break
		elif val[i] == 0 and cnt == 1:
			ans += i
			break
		elif cnt == 0 and val[i] == 1:
			ans += i
			cnt += 1
	print(ans)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	if n == 1:
		if arr[0] != 0:
			print('0')
		else:
			print('1')
		continue
	arr.sort()
	if arr[0] != 0:
		print('0')
		continue
	set1 = [0]
	set2 = []
	el1 = 1
	el2 = 0
	for i in range(1, n):
		if arr[i] == set1[-1]:
			set2.append(arr[i])
			if arr[i] == el2:
				el2 += 1
		else:
			set1.append(arr[i])
			if arr[i] == el1:
				el1 += 1
	print(el1 + el2)


for _ in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	l.sort()
	l1 = []
	l2 = []
	l1.append(l[0])
	for i in range(1, n):
		if l[i] not in l1:
			l1.append(l[i])
		elif l[i] not in l2:
			l2.append(l[i])
		else:
			l1.append(l[i])
	ans1 = 0
	ans2 = 0
	for k in range(101):
		if k not in l1:
			ans1 += k
			break
	for j in range(101):
		if j not in l2:
			ans2 += j
			break
	print(ans1 + ans2)


import os
import sys
from io import BytesIO, IOBase
import math
from decimal import *
getcontext().prec = 30
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split(' ')))
	d = {}
	for i in range(n):
		d[l[i]] = d.get(l[i], 0) + 1
	ans = 0
	x = list(d.keys())
	for i in range(max(x) + 2):
		if d.get(i, 0) < 2:
			ans = i
			break
	for i in range(max(x) + 2):
		if d.get(i, 0) < 1:
			ans += i
			break
	print(ans)


from collections import Counter
for _ in range(int(input())):
	i_liczb = int(input())
	liczby = list(map(int, input().split()))
	conter = Counter(liczby)
	wynik = 0
	cos = True
	for x in range(101):
		if cos:
			if conter[x] >= 2:
				continue
			elif conter[x] == 1:
				cos = False
				wynik += x
			else:
				wynik += 2 * x
				break
		elif conter[x] >= 1:
			continue
		else:
			wynik += x
			break
	print(wynik)


t = int(input())
for i in range(t):
	n = int(input())
	lst = list(map(int, input().strip().split(' ')))
	lst.sort()
	if lst[0] != 0:
		print(0)
	elif n == 1 and lst[0] == 0:
		print(1)
	elif n > 1 and lst[1] != 0:
		lst = list(dict.fromkeys(lst))
		for j in range(len(lst)):
			if lst[j] == j:
				if j == len(lst) - 1:
					print(len(lst))
			else:
				print(j)
				break
	else:
		lst1 = [0]
		lst2 = [0]
		for j in range(2, n):
			if lst[j] == lst1[-1] + 1:
				lst1.append(lst[j])
			elif lst[j] == lst2[-1] + 1:
				lst2.append(lst[j])
			elif lst[j] == lst1[-1] or lst[j] == lst2[-1]:
				continue
			else:
				break
		print(lst1[-1] + lst2[-1] + 2)


T = int(input())
while T >= 1:
	n = int(input())
	arr = list(map(int, input().split()))
	lst = [0] * 101
	size = 2
	res = 0
	for i in arr:
		lst[i] += 1
	while size >= 1:
		check = True
		for i in range(0, 101):
			if lst[i] > 0:
				lst[i] -= 1
			else:
				res += i
				break
		size -= 1
	print(res)
	T -= 1


from collections import Counter

def get_ans(n, arr):
	arr.sort()
	for i in range(len(arr) - 1):
		if arr[i + 1] != arr[i] + 1 and arr[i + 1] != arr[i]:
			arr = arr[:i + 1]
			break
	cter = dict(Counter(arr))
	s = set(arr)
	a = 0
	b = 0
	i = 1
	Fn = False
	if arr[0] != 0:
		return 0
	prev = 0
	for i in s:
		if cter[i] == 1:
			a = i
			break
	if a == 0 and cter[0] != 1:
		a = arr[-1] + 1
	return a + arr[-1] + 1

def dfs(G, v, curr):
	v.append(curr)
	max_d = 1
	v_max_d = []
	tr = False
	for node in range(n):
		if G[curr][node] != -1:
			if node not in v:
				tr = True
				d_v = dfs(G, v, node)
				if d_v[0] + 1 > max_d:
					max_d = d_v[0] + 1
					v_max_d = d_v[1]
	if not tr:
		return (1, v)
	return (max_d, v_max_d)

def bfs(G, start):
	v = []
	querry = []
	v.append(start)
	querry.append(start)
	depth = 0
	while querry:
		depth += 1
		curr = querry.pop(0)
		for node in range(n):
			if G[curr][node] != -1 and node not in v:
				v.append(node)
				querry.append(node)
	return (depth, v)
t = int(input())
anss = []
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	anss.append(get_ans(n, arr))
for i in anss:
	print(i)


import math
import collections
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect_left as bsl
from bisect import bisect_right as bsr
import heapq as hq
setrecursionlimit(2 ** 20)
t = 1
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().rstrip().split()))
	d = {}
	for i in a:
		if i not in d:
			d[i] = 0
		d[i] += 1
	ans1 = 0
	for i in range(0, 102):
		if i not in d:
			ans1 = i
			break
	for j in range(0, ans1):
		if j in d:
			d[j] -= 1
			if d[j] == 0:
				del d[j]
	ans2 = 0
	for i in range(0, 102):
		if i not in d:
			ans2 = i
			break
	print(ans1 + ans2)


cases = int(input())
for _ in range(cases):
	n = int(input())
	c = list(map(int, input().split()))
	l = sorted(c)
	index = 0
	w = []
	m = l.copy()
	if 0 not in l:
		print(0)
		continue
	for i in range(len(l)):
		if index in l:
			w.append(index)
			m.remove(index)
		else:
			break
		index += 1
	tot = max(w) + 1
	m = sorted(list(set(m)))
	index = 0
	for i in range(len(m)):
		if m[i] == index:
			index += 1
		else:
			break
	tot += index
	print(tot)


import sys
t = int(sys.stdin.readline())
ans_arr = []
for i in range(t):
	n = int(sys.stdin.readline())
	a = [int(j) for j in sys.stdin.readline().split()]
	ans = 0
	for mex in range(101):
		tmp = 0
		d = {}
		for p in range(n):
			if a[p] in d:
				d[a[p]] += 1
			else:
				d[a[p]] = 1
		flag = True
		for h in range(mex):
			if h not in d:
				flag = False
				break
			elif d[h] == 0:
				flag = False
				break
			else:
				d[h] -= 1
		if flag:
			tmp = mex
			arr = []
			for k in d:
				if d[k] > 0:
					arr.append(k)
			arr.sort()
			prev = 0
			for w in range(len(arr)):
				if prev == arr[w]:
					prev += 1
				elif prev < arr[w]:
					break
			tmp += prev
			ans = max(ans, tmp)
	ans_arr.append(str(ans))
print('\n'.join(ans_arr))


from bisect import bisect_left, bisect_right
for _ in range(int(input())):
	N = int(input())
	A = list(map(int, input().split()))
	A.sort()
	a = 0
	b = 0
	i = 0
	while i < N:
		if A[i] < a:
			i += 1
		elif A[i] == a:
			a += 1
			i += 1
			if i < N and A[i] == b:
				b += 1
				i += 1
		else:
			break
	print(a + b)


cases = int(input())
for i in range(cases):
	n = int(input())
	arr = list(map(int, input().split()))
	count = [0 for i in range(101)]
	amax = 0
	bmax = 0
	for i in arr:
		count[i] += 1
	for i in range(101):
		if count[i] == 0:
			amax = i
			break
	for i in range(101):
		if count[i] < 2:
			bmax = i
			break
	print(amax + bmax)


T = int(input())
while T:
	n = int(input())
	l = [int(k) for k in input().split()]
	c = [0] * 101
	b = []
	a = []
	nl = []
	for i in l:
		c[i] += 1
	for i in range(101):
		x = min(2, c[i])
		for j in range(x):
			if j == 0:
				a.append(i)
			else:
				b.append(i)
	bl = len(b)
	al = len(a)
	i = 0
	while i < al:
		if a[i] != i:
			nl.append(i)
			break
		i += 1
	if i == al:
		nl.append(i)
	i = 0
	while i < bl:
		if b[i] != i:
			nl.append(i)
			break
		i += 1
	if i == bl:
		nl.append(i)
	print(sum(nl))
	T -= 1


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	x = Counter(a)
	for i in range(101):
		if x[i] == 0:
			print(i * 2)
			break
		elif x[i] == 1:
			s = i
			for j in range(i + 1, 101):
				if x[j] == 0:
					s += j
					break
			else:
				s += 101
			print(s)
			break
	else:
		print(101 * 2)


from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))

def solve():
	n = get_int()
	ls = get_list()
	ls.sort()
	ans = 0
	for i in range(101):
		if i in ls:
			ls.remove(i)
		else:
			ans += i
			break
	for i in range(101):
		if i in ls:
			ls.remove(i)
		else:
			ans += i
			break
	print(ans)

def main():
	solve()
TestCases = True
if TestCases:
	for i in range(get_int()):
		main()
else:
	main()


from bisect import *
from collections import *
from math import gcd, ceil, sqrt, floor, inf
from heapq import *
from itertools import *
from operator import add, mul, sub, xor, truediv, floordiv
from functools import *
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())
farr = [1]
ifa = []

def fact(x, mod=0):
	if mod:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr) % mod)
	else:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr))
	return farr[x]

def ifact(x, mod):
	global ifa
	ifa.append(pow(farr[-1], mod - 2, mod))
	for i in range(x, 0, -1):
		ifa.append(ifa[-1] * i % mod)
	ifa = ifa[::-1]

def per(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return fact(i) // fact(i - j)
	return farr[i] * ifa[i - j] % mod

def com(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return per(i, j) // fact(j)
	return per(i, j, mod) * ifa[j] % mod

def catalan(n):
	return com(2 * n, n) // (n + 1)

def linc(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t > f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rinc(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t < f(mid):
			r = mid - 1
		else:
			l = mid
	return l

def ldec(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t < f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rdec(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t > f(mid):
			r = mid - 1
		else:
			l = mid
	return l

def isprime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True

def binfun(x):
	c = 0
	for w in arr:
		c += ceil(w / x)
	return c

def lowbit(n):
	return n & -n

def inverse(a, m):
	a %= m
	if a <= 1:
		return a
	return (1 - inverse(m, a) * m) // a % m

class BIT:

	def __init__(self, arr):
		self.arr = arr
		self.n = len(arr) - 1

	def update(self, x, v):
		while x <= self.n:
			self.arr[x] += v
			x += x & -x

	def query(self, x):
		ans = 0
		while x:
			ans += self.arr[x]
			x &= x - 1
		return ans

class smt:

	def __init__(self, l, r, arr):
		self.l = l
		self.r = r
		self.value = (1 << 31) - 1 if l < r else arr[l]
		mid = (l + r) // 2
		if l < r:
			self.left = smt(l, mid, arr)
			self.right = smt(mid + 1, r, arr)
			self.value &= self.left.value & self.right.value

	def setvalue(self, x, val):
		if self.l == self.r:
			self.value = val
			return
		mid = (self.l + self.r) // 2
		if x <= mid:
			self.left.setvalue(x, val)
		else:
			self.right.setvalue(x, val)
		self.value = self.left.value & self.right.value

	def ask(self, l, r):
		if l <= self.l and r >= self.r:
			return self.value
		val = (1 << 31) - 1
		mid = (self.l + self.r) // 2
		if l <= mid:
			val &= self.left.ask(l, r)
		if r > mid:
			val &= self.right.ask(l, r)
		return val

class DSU:

	def __init__(self, n):
		self.c = [-1] * n

	def same(self, x, y):
		return self.find(x) == self.find(y)

	def find(self, x):
		if self.c[x] < 0:
			return x
		self.c[x] = self.find(self.c[x])
		return self.c[x]

	def union(self, u, v):
		(u, v) = (self.find(u), self.find(v))
		if u == v:
			return False
		if self.c[u] < self.c[v]:
			(u, v) = (v, u)
		self.c[u] += self.c[v]
		self.c[v] = u
		return True

	def size(self, x):
		return -self.c[self.find(x)]

class UFS:

	def __init__(self, n):
		self.parent = [i for i in range(n)]
		self.ranks = [0] * n

	def find(self, x):
		if x != self.parent[x]:
			self.parent[x] = self.find(self.parent[x])
		return self.parent[x]

	def union(self, u, v):
		(pu, pv) = (self.find(u), self.find(v))
		if pu == pv:
			return False
		if self.ranks[pu] >= self.ranks[pv]:
			self.parent[pv] = pu
			if self.ranks[pv] == self.ranks[pu]:
				self.ranks[pu] += 1
		else:
			self.parent[pu] = pv

def Prime(n):
	c = 0
	prime = []
	flag = [0] * (n + 1)
	for i in range(2, n + 1):
		if not flag[i]:
			prime.append(i)
			c += 1
		for j in range(c):
			if i * prime[j] > n:
				break
			flag[i * prime[j]] = prime[j]
			if i % prime[j] == 0:
				break
	return prime

def dij(s, graph):
	d = {}
	d[s] = 0
	heap = [(0, s)]
	seen = set()
	while heap:
		(dis, u) = heappop(heap)
		if u in seen:
			continue
		for v in graph[u]:
			if v not in d or d[v] > d[u] + graph[u][v]:
				d[v] = d[u] + graph[u][v]
				heappush(heap, (d[v], v))
	return d

def GP(it):
	return [(ch, len(list(g))) for (ch, g) in groupby(it)]

class DLN:

	def __init__(self, val):
		self.val = val
		self.pre = None
		self.next = None
t = N()
for i in range(t):
	n = N()
	a = RLL()
	c = Counter(a)
	x = []
	y = []
	for k in sorted(c.keys()):
		if c[k] != 1:
			y.append(k)
		x.append(k)
	(m, n) = (len(x), len(y))
	for (i, a) in enumerate(x):
		if i != a:
			m = i
			break
	for (i, a) in enumerate(y):
		if i != a:
			n = i
			break
	ans = m + n
	print(ans)


def f(l):
	for j in range(max(l) + 2):
		if j not in l:
			return j
			break
for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l1 = []
	l2 = []
	mex = 0
	for i in l:
		if i not in l1:
			l1.append(i)
		else:
			l2.append(i)
	if len(l2) > 0:
		mex = f(l1) + f(l2)
	else:
		mex = f(l1)
	print(mex)


def checker(a):
	s = set(a)
	for i in range(len(a) + 1):
		if i not in s:
			return i
for _ in range(int(input())):
	m = int(input())
	lst = [int(i) for i in input().split()][:]
	x = [0] * 102
	for i in set(lst):
		x[i] = lst.count(i)
	for i in range(len(x)):
		if x[i] <= 1:
			k = i
			break
	print(checker(lst) + k)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort(reverse=False)
	(s, b) = (0, 0)
	for i in a:
		if s == i:
			s += 1
		elif b == i:
			b += 1
	print(b + s)


for _ in range(int(input())):
	t = int(input())
	a = 0
	b = 0
	for i in sorted(map(int, input().split())):
		if i == a:
			a += 1
		elif i == b:
			b += 1
	print(a + b)


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	a = 0
	br = 0
	g = True
	for j in range(0, max(arr) + 1):
		if arr.count(j) >= 2 and g == True:
			a = j + 1
			br = j + 1
		elif arr.count(j) >= 1 and abs(j - a) == 0:
			g = False
			a = j + 1
		else:
			break
	print(br + a)


from sys import stdin, stdout
import heapq as hq
from collections import defaultdict
t = int(input())
for tc in range(t):
	n = int(stdin.readline())
	ar = list(map(int, stdin.readline().split()))
	c = defaultdict(int)
	for v in ar:
		c[v] += 1
	for i in range(102):
		if c[i] < 2:
			break
	for j in range(102):
		if c[j] < 1:
			break
	stdout.write(str(i + j) + '\n')


import sys, math, cmath, time
start_time = time.time()

def solve():
	n = inp()
	a = inlt()
	q = counter(a)
	qw = 0
	for i in range(len(q)):
		if q[i] == 0:
			if qw == 0:
				qq = 2 * i
			else:
				qq = qq + i
			break
		if q[i] == 1 and qw == 0:
			if qw == 0:
				qq = i
				qw = 1
	print(qq)

def main():
	global tt
	if not ONLINE_JUDGE:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	t = 1
	t = inp()
	for tt in range(t):
		solve()
	if not ONLINE_JUDGE:
		print('Time Elapsed :', time.time() - start_time, 'seconds')
		sys.stdout.close()

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	return input().strip()

def invr():
	return map(int, input().split())

def counter(a):
	q = [0] * (max(a) + 2)
	for i in range(len(a)):
		q[a[i]] = q[a[i]] + 1
	return q

def counter_elements(a):
	q = dict()
	for i in range(len(a)):
		if a[i] not in q:
			q[a[i]] = 0
		q[a[i]] = q[a[i]] + 1
	return q

def string_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
	return q

def factors(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.append(i)
			q.append(n // i)
	return list(sorted(list(set(q))))

def prime_factors(n):
	q = []
	while n % 2 == 0:
		q.append(2)
		n = n // 2
	for i in range(3, int(n ** 0.5) + 1, 2):
		while n % i == 0:
			q.append(i)
			n = n // i
	if n > 2:
		q.append(n)
	return list(sorted(q))

def transpose(a):
	(n, m) = (len(a), len(a[0]))
	b = [[0] * n for i in range(m)]
	for i in range(m):
		for j in range(n):
			b[i][j] = a[j][i]
	return b

def factorial(n, m=1000000007):
	q = 1
	for i in range(n):
		q = q * (i + 1) % m
	return q
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
	input = sys.stdin.readline
main()


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(ri()):
		n = ri()
		a = ria()
		d = Counter(a)
		c = 0
		ans = 0
		for i in range(101):
			if i in d and d[i] > 0:
				d[i] -= 1
			else:
				ans += i
				break
		for i in range(101):
			if i in d and d[i] > 0:
				d[i] -= 1
			else:
				ans += i
				break
		print(ans)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


for _ in range(int(input())):
	N = int(input())
	array = list(map(int, input().split()))
	dic = {}
	for i in array:
		if i not in dic.keys():
			dic[i] = 1
		else:
			dic[i] += 1
	set_1 = []
	set_2 = []
	ans = 0
	for i in range(101):
		if dic.get(i, -1) > 0:
			dic[i] -= 1
		else:
			ans += i
			break
	for i in range(101):
		if dic.get(i, -1) > 0:
			dic[i] -= 1
		else:
			ans += i
			break
	print(ans)


from collections import defaultdict
for i in range(int(input())):
	n = int(input())
	arr = [int(i) for i in input().split()]
	cnt = defaultdict(int)
	for i in arr:
		cnt[i] += 1
	first = 0
	second = 0
	tot = 0
	for j in range(0, max(arr) + 2):
		if cnt[j] == 0:
			first = j
			break
	res = 0
	for t in range(0, max(arr) + 2):
		if cnt[t] == 1 or cnt[t] == 0:
			second = t
			break
	print(first + second)


T = int(input())
from collections import Counter
for _ in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	ctr = Counter(A)
	a = b = -1
	for i in range(101):
		if ctr[i] >= 2:
			continue
		if a == -1 and ctr[i] == 1:
			a = i
		if ctr[i] == 0:
			b = i
			if a == -1:
				a = i
			break
	print(a + b)


t = int(input())
for _ in range(t):
	n = int(input())
	tab = list(map(int, input().split()))
	arr = [0] * 101
	for i in tab:
		arr[i] += 1
	sol = 0
	it = 0
	while arr[it] >= 2:
		it += 1
	sol += it
	while arr[it] >= 1:
		it += 1
	sol += it
	print(sol)


rw = int(input())
for wewq in range(rw):
	n = int(input())
	a = list(map(int, input().split()))
	b = 0
	c = 0
	for i in range(max(a) + 1):
		f = a.count(i)
		if f == 0:
			break
		elif f == 1:
			b += 1
		elif f >= 2 and b == c:
			b += 1
			c += 1
		elif f >= 2 and b != c:
			b += 1
	print(b + c)


def mex(arr):
	if len(arr) == 0:
		return 0
	arr.sort()
	if arr[0] > 0:
		return 0
	for i in range(len(arr) - 1):
		if arr[i + 1] - arr[i] > 1:
			return arr[i] + 1
	return arr[-1] + 1
num_test_cases = int(input())
for i in range(num_test_cases):
	size = int(input())
	occ = {}
	my_set = []
	tmp = input().strip().split(' ')
	for n in tmp:
		m = int(n)
		my_set.append(m)
		occ[m] = occ.get(m, 0) + 1
	keys_sorted = sorted(occ)
	my_set = []
	for key in keys_sorted:
		if occ[key] >= 2:
			my_set += [key, key]
		else:
			my_set += [key]
	if my_set[0] != 0:
		print(0)
		continue
	if len(my_set) > 1 and my_set[1] == 0:
		i = 1
		end = len(keys_sorted)
		while True and i < end:
			if keys_sorted[i] != i or occ[keys_sorted[i]] < 2:
				break
			i += 1
		if i == end:
			result = (keys_sorted[i - 1] + 1) * 2
		elif occ[keys_sorted[i]] >= 2:
			result = i * 2
		elif keys_sorted[i] == i:
			i += 1
			result = i
			while True and i < end:
				if keys_sorted[i] != i:
					break
				i += 1
			result += keys_sorted[i - 1]
		else:
			result = i * 2
		print(result)
	else:
		print(mex(my_set))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	dic = {}
	for i in range(101):
		dic[i] = 0
	for i in ar:
		dic[i] += 1
	p1 = 0
	p2 = 0
	for i in range(101):
		if p1 == i and dic[i] > 0:
			p1 += 1
			dic[i] -= 1
		if p2 == i and dic[i] > 0:
			p2 += 1
			dic[i] -= 1
	print(p1 + p2)


t = int(input())
for j in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	f = [0] * 101
	for ll in range(0, n):
		f[a[ll]] += 1
	o = 0
	p = 0
	k = 0
	for ii in range(0, 101):
		if k == 0:
			if f[ii] >= 2:
				o = o + 1
				p = p + 1
			elif f[ii] == 1:
				o = o + 1
				k = -1
			else:
				break
		elif f[ii] >= 1:
			o = o + 1
		else:
			break
	print(o + p)


from math import *
from bisect import *
from collections import *
from random import *
from decimal import *
import sys
input = sys.stdin.readline

def inp():
	return int(input())

def st():
	return input().rstrip('\n')

def lis():
	return list(map(int, input().split()))

def ma():
	return map(int, input().split())
t = inp()
while t:
	t -= 1
	n = inp()
	a = lis()
	co = [0] * 102
	for i in a:
		co[i] += 1
	a = []
	b = []
	a.sort()
	po = 0
	fl = 0
	s = 0
	for i in range(101):
		if co[i] >= 2:
			continue
		if co[i] == 0:
			if fl == 0:
				s += 2 * i
			else:
				s += i
			break
		elif fl == 0 and co[i] == 1:
			fl = 1
			s += i
		elif fl == 1 and co[i] == 0:
			s += i
			break
	print(s)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))[:n]
	a = sorted(a)
	(b, c) = ([], [])
	for i in range(n):
		if a[i] not in b:
			b.append(a[i])
		else:
			c.append(a[i])
	(x, y) = (0, 0)
	while x in b:
		x = x + 1
	while y in c:
		y = y + 1
	print(x + y)


T = int(input())
for _ in range(T):
	n = int(input())
	A = list(map(int, input().split()))
	B = [0] * 101
	for i in range(n):
		B[A[i]] += 1
	ans = 0
	for i in range(0, 101):
		if B[i] == 0:
			ans = ans + i
			if i != 0:
				for j in range(i - 1, -1, -1):
					if B[j] != 0:
						B[j] -= 1
			break
	for i in range(0, 101):
		if B[i] == 0:
			ans = ans + i
			break
	print(ans)


import sys
import math
from math import *
from collections import Counter, defaultdict, deque
lip = lambda : list(map(int, input().split()))
ip = lambda : int(input())
sip = lambda : input().split()

def main():
	n = ip()
	arr = lip()
	set1 = set()
	set2 = set()
	d1 = defaultdict(lambda : False)
	d2 = defaultdict(lambda : False)
	for i in arr:
		if i in set1:
			set2.add(i)
			d2[i] = True
		else:
			d1[i] = True
			set1.add(i)
	A = 0
	for i in range(len(set1) + 2):
		if not d1[i]:
			A = i
			break
	B = 0
	for i in range(len(set2) + 2):
		if not d2[i]:
			B = i
			break
	print(A + B)
for i in range(ip()):
	main()


from collections import Counter
for ad in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	c = Counter(l)
	ans = 0
	left = 2
	for i in range(102):
		if c[i] == 0:
			ans = 2 * i
			left = 0
			break
		elif c[i] == 1:
			left = 1
			ans = i
			x = i
			break
	if left == 1:
		for j in range(x + 1, 102):
			if c[j] == 0:
				ans += j
				break
	print(ans)


def mex(arr):
	arr = set(arr)
	for i in range(len(arr) + 2):
		if i not in arr:
			return i
for _ in range(int(input())):
	n = int(input())
	(*arr,) = map(int, input().split())
	mx = 0
	arr_mex = mex(arr)
	for i in range(arr_mex):
		arr.remove(i)
	new_mex = mex(arr)
	print(arr_mex + new_mex)


for t in range(int(input())):
	occ = [0] * 120
	n = int(input())
	a = [int(x) for x in input().split()]
	for x in a:
		occ[x] += 1
	fl = 1
	ok = 0
	m1 = -1
	for i in range(len(occ)):
		if occ[i] == 0:
			m1 = i
			break
		else:
			occ[i] -= 1
	m2 = -1
	for i in range(len(occ)):
		if occ[i] == 0:
			m2 = i
			break
		else:
			occ[i] -= 1
	print(m1 + m2)


def mex(l):
	cur = -1
	for e in l:
		if e in [cur, cur + 1]:
			cur = e
		else:
			break
	return cur + 1
for _ in range(int(input())):
	n = int(input())
	l = sorted(map(int, input().split()))
	(a, b) = ([], [])
	for e in l:
		if a and e <= a[-1]:
			b.append(e)
		else:
			a.append(e)
	print(mex(a) + mex(b))


for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	m1 = m2 = 0
	for i in range(0, 101):
		if i in li:
			li.remove(i)
		else:
			m1 = i
			break
	for i in range(0, 101):
		if i in li:
			li.remove(i)
		else:
			m2 = i
			break
	print(m1 + m2)


for __ in range(int(input())):
	n = int(input())
	c = [0 for _ in range(101)]
	a = input().split()
	for x in a:
		c[int(x)] += 1
	k = 0
	while c[k] >= 2:
		k += 1
	p = 0
	while c[p]:
		p += 1
	print(p + k)


import sys
input = sys.stdin.readline
from math import gcd
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = 0
	i = 0
	while True:
		if i in arr:
			ans += 1
			arr.remove(i)
		else:
			break
		i += 1
	i = 0
	while True:
		if i in arr:
			ans += 1
			arr.remove(i)
		else:
			break
		i += 1
	print(ans)


(T,) = map(int, input().split())
from collections import defaultdict
for _ in range(T):
	(N,) = map(int, input().split())
	X = list(map(int, input().split()))
	D = defaultdict(int)
	for x in X:
		D[x] += 1
	f = 0
	for i in range(N + 1):
		if D[i] < 2:
			f = i
			break
	for i in range(N + 1):
		if D[i] < 1:
			f2 = i
			break
	print(f + f2)


import sys
import random
input = sys.stdin.readline
cases = int(input())
for case in range(cases):
	n = int(input())
	a = [int(x) for x in input().split()]
	s = set()
	a.sort()
	(ans, mex, b) = (0, 0, [])
	if a[0] != 0:
		print(0)
		continue
	s.add(a[0])
	for i in range(1, len(a)):
		if a[i] - a[i - 1] > 1:
			break
		if not a[i] in s:
			s.add(a[i])
			mex = max(mex, a[i])
		else:
			b.append(a[i])
	mex += 1
	ans += mex
	if len(b) == 0:
		print(ans)
		continue
	if b[0] != 0:
		print(ans)
		continue
	mex = 0
	for i in range(1, len(b)):
		if b[i] - b[i - 1] > 1:
			break
		mex = max(mex, b[i])
	mex += 1
	ans += mex
	print(ans)


t = int(input())
for tc in range(t):
	n = int(input())
	line = input().split()
	arr = []
	arr2 = []
	indices = []
	for i in range(n):
		arr.append(int(line[i]))
	arr.sort()
	for i in range(1, n):
		if arr[i] == arr[i - 1]:
			indices.append(i)
			arr2.append(arr[i])
	for i in indices:
		arr[i] = -1
	ans = 0
	i = 0
	j = 0
	if len(arr) > 0 and len(arr2) > 0:
		while 1:
			if i in arr:
				i += 1
			else:
				ans += i
				break
		while 1:
			if j in arr2:
				j += 1
			else:
				ans += j
				break
	elif len(arr) == 0:
		while 1:
			if j in arr2:
				j += 1
			else:
				ans += j
				break
	elif len(arr2) == 0:
		while 1:
			if i in arr:
				i += 1
			else:
				ans += i
				break
	print(ans)


import sys

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math
from collections import defaultdict
for _ in range(ri()):
	n = ri()
	l = ria()
	l.sort()
	x = 0
	d = defaultdict(int)
	for i in l:
		d[i] += 1
	k = list(d.keys())
	v = list(d.values())
	a = []
	b = []
	for i in range(len(k)):
		if v[i] > 1:
			a.append(k[i])
			b.append(k[i])
		elif v[i] == 1:
			a.append(k[i])
	for i in range(101):
		if i not in a:
			x += i
			break
	for i in range(101):
		if i not in b:
			x += i
			break
	wi(x)


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		s = list(map(int, input().split()))
		d = [0] * 101
		for i in s:
			d[i] += 1
		f = [0, 0]
		k = 2
		i = 0
		while k > 0:
			if d[i] == 0:
				if k == 2:
					(f[0], f[1]) = (i, i)
				elif k == 1:
					f[0] = i
				k -= 2
			elif d[i] == k - 1:
				f[k - 1] = i
				k -= 1
			i += 1
		print(f[0] + f[1])
main()


import sys as _sys

def main():
	t = int(input())
	for i in range(t):
		(n,) = _read_ints()
		a = tuple(_read_ints())
		result = find_max_two_subsets_mex_sum(a)
		print(result)

def _read_line():
	result = _sys.stdin.readline()
	assert result[-1] == '\n'
	return result[:-1]

def _read_ints():
	return map(int, _read_line().split(' '))

def find_max_two_subsets_mex_sum(sequence):
	sequence = sorted(sequence)
	a_last = -1
	b_last = -1
	for x in sequence:
		a_next = a_last + 1
		if x == a_next:
			a_last = x
			continue
		b_next = b_last + 1
		if x == b_next:
			b_last = x
			continue
	return a_last + 1 + (b_last + 1)
main()


import sys
from collections import Counter
input = sys.stdin.readline
for nt in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	c = Counter(a)
	flag = 0
	ans = 0
	for i in range(max(a) + 2):
		if c[i] == 1:
			if not flag:
				ans = i
				flag = 1
		elif c[i] == 0:
			if not flag:
				ans = 2 * i
			else:
				ans += i
			break
	print(ans)


for _ in range(int(input())):
	n = int(input())
	arr = sorted(list(map(int, input().split())))
	mex1 = 0
	mex2 = 0
	for elem in arr:
		if elem == mex1:
			mex1 += 1
		elif elem == mex2:
			mex2 += 1
	print(mex1 + mex2)


import os
import sys
from io import BytesIO, IOBase

def main():
	T = iin()
	while T:
		T -= 1
		n = iin()
		a = lin()
		dc = {}
		for i in a:
			try:
				dc[i] += 1
			except:
				dc[i] = 1
		ch = 0
		(a1, a2) = ([-1], [-1])
		while ch in dc:
			if a1[-1] + 1 == ch and dc[ch]:
				dc[ch] -= 1
				a1.append(ch)
			if a2[-1] + 1 == ch and dc[ch]:
				dc[ch] -= 1
				a2.append(ch)
			ch += 1
		print(a1[-1] + 1 + a2[-1] + 1)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def iin():
	return int(input())

def lin():
	return list(map(int, input().split()))
main()


import random

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	curr = 0
	d = {}
	ans = []
	for i in a:
		if i not in d:
			d[i] = 1
		else:
			d[i] += 1
	while len(ans) < 2:
		if curr in d:
			if d[curr] == 1 and len(ans) == 0:
				ans.append(curr)
		else:
			ans.append(curr)
			ans.append(curr)
		curr += 1
	print(ans[0] + ans[1])


from sys import stdin

def inp():
	return stdin.buffer.readline().rstrip().decode('utf8')

def itg():
	return int(stdin.buffer.readline())

def mpint():
	return map(int, stdin.buffer.readline().split())
from collections import Counter
for __ in range(itg()):
	n = itg()
	c = Counter(mpint())
	ans = v = 0
	for k in range(101):
		if v is None:
			if c[k]:
				ans += 1
			else:
				break
		elif c[k] >= 2:
			ans += 1
			v += 1
		elif c[k] == 1:
			ans += 1 + v
			v = None
		else:
			ans += v
			break
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	x = [int(x) for x in input().split()]
	x.sort()
	a = set(x)
	b = []
	for item in a:
		if x.count(item) > 1:
			b.append(item)

	def func(x):
		if x == []:
			return 0
		for i in range(0, max(x) + 2):
			if i in x:
				continue
			else:
				return i
	print(func(a) + func(b))


from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	d = Counter(arr)
	for ele in d:
		if d[ele] > 2:
			d[ele] = 2
	maximum1 = 0
	maximum2 = 0
	n = len(arr)
	for i in range(0, len(arr)):
		if i in d:
			if d[i] == 2:
				maximum1 += 1
				maximum2 += 1
			else:
				maximum1 += 1
				break
		else:
			break
	if i in d:
		i += 1
		while i in d:
			maximum1 += 1
			i += 1
	print(maximum1 + maximum2)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	output = 0
	lis = list(map(int, input().split()))
	dic = Counter(lis)
	c = 0
	for i in range(101):
		if i in dic:
			dic[i] -= 1
			if dic[i] == 0:
				del dic[i]
			continue
		else:
			output += i
			break
	for i in range(101):
		if i in dic:
			dic[i] -= 1
			if dic[i] == 0:
				del dic[i]
			continue
		else:
			output += i
			break
	print(output)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split(' ')))
	(l, l1) = ([], [])
	i = 0
	c = min(a)
	if c > 0:
		print(0)
	else:
		while a.count(i) > 0:
			if a.count(i) >= 2:
				l1.append(i)
			elif a.count(i) == 1:
				l.append(i)
			i += 1
		if len(l1) > 0:
			k = min(l1)
			if k == 0 and len(l) > 0:
				c = l[0]
			elif k == 0 and len(l) == 0:
				c = max(l1) + 1
			elif k > 0:
				c = 0
		elif len(l1) == 0:
			if len(l) > 0:
				c = 0
		print(i + c)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(set(a))
	b.sort()
	j = 0
	l = len(b)
	p = []
	c = 0
	while j < l:
		if b[j] != j:
			c = j
			break
		else:
			p.append(b[j])
			j = j + 1
	else:
		c = j
	j = 0
	while j <= c:
		if a.count(j) <= 1:
			v = j
			break
		else:
			j = j + 1
	print(c + v)


t = int(input())
for _ in range(t):
	N = int(input())
	a = list(map(int, input().split()))
	nums = [0] * 101
	for i in range(N):
		nums[a[i]] += 1
	now = 0
	while nums[now] >= 2:
		now += 1
	now2 = 0
	while nums[now2] >= 1:
		now2 += 1
	print(now + now2)


import os
import sys
from io import BytesIO, IOBase

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def prime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def divisors(n):
	i = 1
	div = []
	while i <= math.sqrt(n):
		if n % i == 0:
			if n / i == i:
				div.append(i)
			else:
				div.append(i)
				div.append(n // i)
		i = i + 1
	return div

def solve():
	for _ in range(int(input())):
		n = int(input())
		arr = list(map(int, input().split()))
		cnt = [0] * 101
		for i in arr:
			cnt[i] += 1
		ans = 0
		flag1 = 1
		flag2 = 1
		for i in range(len(cnt)):
			if cnt[i] == 0 and flag1 == 1:
				ans = ans + i
				flag1 = 0
			if cnt[i] <= 1 and flag2 == 1:
				ans = ans + i
				flag2 = 0
			if flag1 == 0 and flag2 == 0:
				break
		print(ans)

def main():
	solve()
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
while t > 0:
	nr_mex = 2
	sum = 0
	nr = []
	n = int(input())
	aux = input()
	for i in range(102):
		nr.append(0)
	for i in range(n):
		val = int(aux.split()[i])
		nr[val] += 1
	for i in range(102):
		if nr[i] < nr_mex:
			if nr[i] == 0 and nr_mex == 2:
				sum += i
				nr_mex -= 1
			sum += i
			nr_mex -= 1
		if nr_mex == 0:
			break
	print(sum)
	t -= 1


T = int(input())
while T > 0:
	n = int(input())
	arr = list(map(int, input().split()))
	count = [0] * 101
	for x in arr:
		count[x] += 1
	res = 0
	final = 0
	for i in range(101):
		final = i
		if count[i] == 0:
			break
		else:
			count[i] -= 1
	res += final
	final = 0
	for i in range(101):
		final = i
		if count[i] == 0:
			break
		else:
			count[i] -= 1
	res += final
	print(res)
	T -= 1


T = int(input())
while T:
	N = int(input())
	A = list(map(int, input().split()))
	ans = 0
	for i in range(0, max(A) + 2):
		c = 0
		for j in A:
			if j == i:
				c += 1
		if c >= 2:
			continue
		if c == 0:
			ans = 2 * i
			break
		else:
			ans += i
			i += 1
			while i <= max(A):
				if i not in A:
					break
				i += 1
			ans += i
			break
	print(ans)
	T -= 1


k = int(input())
for _ in range(k):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	check = 0
	b_check = 0
	stack = 0
	(a, b) = (0, 0)
	for e in arr:
		if e == check:
			stack += 1
			if stack >= 3:
				continue
		elif e != check:
			check += 1
			stack = 1
			if e == a and e != b:
				b_check = 1
			elif e != a and e != b:
				break
		if check == a and stack == 1:
			a += 1
		elif check == b and stack == 2 and (b_check == 0):
			b += 1
	print(a + b)


from sys import *
input = stdin.readline
t = int(input())
for case in range(t):
	n = int(input())
	arr = [*map(int, input().split())]
	arr.sort()
	(mex_a, mex_b) = (0, 0)
	for i in range(n):
		if arr[i] == mex_a:
			mex_a += 1
			arr[i] = -1
		elif arr[i] > mex_a:
			break
	for i in range(n):
		if arr[i] == -1:
			continue
		if arr[i] == mex_b:
			mex_b += 1
			arr[i] = -1
		elif arr[i] > mex_b:
			break
	print(mex_a + mex_b)


t = int(input())
for i in range(t):
	n = int(input())
	a = sorted([int(x) for x in input().split()])
	l1 = [a[0]]
	l2 = []
	for j in range(1, n):
		if l1[-1] == a[j]:
			l2.append(a[j])
		else:
			l1.append(a[j])
	b1 = True
	if len(l1) == 0:
		m1 = 0
	else:
		for j in range(len(l1)):
			if j not in l1:
				m1 = j
				b1 = False
				break
	if b1:
		m1 = len(l1)
	b2 = True
	if len(l2) == 0:
		m2 = 0
	else:
		for j in range(len(l2)):
			if j not in l2:
				m2 = j
				b2 = False
				break
	if b2:
		m2 = len(l2)
	print(m1 + m2)


for _ in ' ' * int(input()):
	z = int(input())
	a = sorted(map(int, input().split()))
	(c, d) = ([], [])
	for i in range(z):
		if a[i] in c:
			d.append(a[i])
		else:
			c.append(a[i])
	i = 0
	while i in c:
		i += 1
	j = 0
	while j in d:
		j += 1
	print(i + j)


import math
import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().rstrip().split()))
	(m1, m2) = (-1, -1)
	for i in range(101):
		if m1 != -1 and m2 != -1:
			break
		c = a.count(i)
		if c == 0:
			if m1 == -1:
				m1 = m2 = i
			else:
				m2 = i
		if c == 1:
			if m1 == -1:
				m1 = i
	print(m1 + m2)


t = int(input())
while t:
	arr = [0] * 102
	t -= 1
	n = int(input())
	l = list(map(int, input().split()))
	for i in l:
		arr[i] += 1
	a = -1
	b = -1
	for (i, v) in enumerate(arr):
		if v == 1 and a == -1:
			a = i
		if v == 0:
			b = i
			if a == -1:
				a = i
			break
	print(a + b)


from sys import stdin
input = stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	f = [0] * 102
	for i in a:
		f[i] += 1
	for i in range(101):
		if f[i] < 2:
			mex1 = i
			break
	for i in range(101):
		if f[i] == 0:
			mex2 = i
			break
	ans = mex1 + mex2
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	dic = dict()
	for i in range(0, 101):
		dic[i] = 0
	for i in a:
		dic[i] += 1
	res = 0
	temp = True
	for i in dic:
		if dic[i] >= 2:
			continue
		elif temp == True and dic[i] == 1:
			res += i
			temp = False
		elif temp == True and dic[i] == 0:
			res = 2 * i
			break
		elif temp == False and dic[i] == 1:
			continue
		elif temp == False and dic[i] == 0:
			res += i
			break
	print(res)


from collections import Counter
t = int(input())
for i in range(t):
	a = input()
	nums = list(map(int, input().split()))
	nums = Counter(nums)
	cur = 0
	while nums[cur]:
		cur += 1
	ans = cur
	cur = 0
	while nums[cur] > 1:
		cur += 1
	ans += cur
	print(ans)


from sys import stdin, stdout, setrecursionlimit
import heapq
from math import gcd, ceil, sqrt
from collections import Counter, deque
from bisect import bisect_left, bisect_right
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
setrecursionlimit(100000)
mod = 1000000007
tc = ii1()
for _ in range(tc):
	n = ii1()
	arr = iia()
	(a, b) = (set(), set())
	for i in arr:
		if i not in a:
			a.add(i)
		elif i not in b:
			b.add(i)
	a = list(sorted(a))
	b = list(sorted(b))
	for i in range(len(a)):
		if a[i] != i:
			res = i
			break
	else:
		res = max(a) + 1
	for i in range(len(b)):
		if b[i] != i:
			res += i
			break
	else:
		if len(b):
			res += max(b) + 1
	print(res)


import random
import sys
import os
t = int(input())
for ti in range(t):
	both = 1
	ans = 0
	n = int(input())
	v = list(map(int, input().split()))
	v.sort()
	nr = 0
	i = 0
	while i < n:
		if v[i] != nr:
			break
		cnt = 1
		while i + 1 < n and v[i] == v[i + 1]:
			cnt += 1
			i += 1
		if not cnt:
			break
		if cnt == 1:
			both = 0
		ans += 1 + both
		nr += 1
		i += 1
	print(ans)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	c = 101
	d = 101
	x = Counter(l)
	for i in range(101):
		if x.get(i, 0) < 2:
			c = i
			break
	for j in range(101):
		if x.get(j, 0) == 0:
			d = j
			break
	print(c + d)


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	b = list()
	x = 0
	c = 0
	A = 0
	B = 0
	flag = 0
	flag1 = 0
	while c < 2:
		if flag == 0 and a.count(x) == 0:
			c += 1
			flag = 1
			A = x
		if flag1 == 0 and a.count(x) <= 1:
			B = x
			c += 1
			flag1 = 1
		x += 1
	print(A + B)
	t -= 1


import math
import sys
import itertools
import fractions
wtf = sys.stdin.read()
wtf = wtf.strip().split('\n')
GAP = 2
for t in [wtf[i:i + GAP] for i in range(1, len(wtf), GAP)]:
	n = int(t[0])
	A = list(map(int, t[1].split()))
	d = dict(((i, 0) for (i, v) in enumerate(range(101))))
	for a in A:
		d[a] += 1
	ans = 0
	for i in range(2):
		i = 0
		while d[i] > 0:
			d[i] -= 1
			i += 1
		ans += i
	print(ans)


def mex(l):
	l.sort()
	if len(l) == 0:
		return 0
	elif l[0] != 0:
		return 0
	else:
		base = 0
		for m in range(1, len(l)):
			if l[m] - base >= 2:
				break
			else:
				base = l[m]
		base += 1
		return base
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	d = {}
	for item in l:
		d[item] = d.get(item, 0) + 1
	a = list(set(l))
	b = []
	for itm in a:
		d[itm] = d.get(itm) - 1
	for it in l:
		if d[it] > 0:
			b.append(it)
	print(mex(a) + mex(b))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	N = int(input())
	a = list(map(int, input().split()))
	table = [0] * 101
	for x in a:
		table[x] += 1
	res = -1
	for i in range(101):
		if table[i] < 2:
			if table[i] == 0:
				if res == -1:
					res = i
				res += i
				break
			elif res == -1:
				res = i
	print(res)


import sys
input = sys.stdin.buffer.readline
Q = int(input())
for _ in range(Q):
	N = int(input())
	A = list(map(int, input().split()))
	B = [0] * 101
	for a in A:
		B[a] += 1
	a1 = 0
	u1 = False
	u2 = False
	a2 = 0
	for (n, b) in enumerate(B):
		if b >= 2 and (not u1):
			a1 = n + 1
		else:
			u1 = True
		if b >= 1 and (not u2):
			a2 = n + 1
		else:
			u2 = True
	print(a1 + a2)


import sys, bisect
input = sys.stdin.buffer.readline
T = int(input())
for testcase in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	flag = [True] * n
	res = -1
	for j in range(101):
		k = bisect.bisect_left(a, j)
		if k < n and a[k] == j:
			flag[k] = False
			res = j
		else:
			break
	c = []
	for i in range(n):
		if flag[i]:
			c.append(a[i])
	ans = -1
	c = list(set(c))
	for e in c:
		if e == ans + 1:
			ans = e
		else:
			break
	print(ans + res + 2)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	d = dict()
	(lst, lst1) = ([], [])
	for i in a:
		d[i] = d.get(i, 0) + 1
	for (i, j) in d.items():
		if d[i] % 2 == 0:
			lst += [i] * (d[i] // 2)
			lst1 += [i] * (d[i] // 2)
		else:
			lst += [i] * (d[i] // 2 + 1)
			lst1 += [i] * (d[i] // 2)
	lst = list(set(lst))
	lst1 = list(set(lst1))
	(p, q) = (0, 0)
	if lst != []:
		for i in range(max(lst) + 2):
			if i not in lst:
				p = i
				break
	if lst1 != []:
		for j in range(max(lst1) + 2):
			if j not in lst1:
				q = j
				break
	print(p + q)


from bisect import bisect_left
import os
import sys
from io import BytesIO, IOBase
from collections import Counter, defaultdict
from collections import deque
from functools import cmp_to_key
import math
import heapq

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
MAX = float('inf')
MIN = float('-inf')
MOD = 1000000007

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	s = set()
	for p in range(2, n + 1):
		if prime[p]:
			s.add(p)
	return s

def readTree(n, m):
	adj = [deque([]) for _ in range(n + 1)]
	for _ in range(m):
		(u, v) = ain()
		adj[u].append(v)
		adj[v].append(u)
	return adj

def main():
	for _ in range(iin()):
		n = iin()
		l = ain()
		a = [0] * 101
		for i in l:
			a[i] += 1
		m1 = 101
		for i in range(101):
			if a[i] == 0:
				m1 = i
				break
			else:
				a[i] -= 1
		m2 = 101
		for i in range(101):
			if a[i] == 0:
				m2 = i
				break
			else:
				a[i] -= 1
		print(m1 + m2)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if os.getcwd() == 'D:\\code':
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def mex(l):
	for i in range(101):
		if i not in l:
			return i
for _ in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	l1 = []
	l2 = []
	x.sort()
	for each in x:
		if each in l1:
			l2.append(each)
		else:
			l1.append(each)
	print(mex(l1) + mex(l2))


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr = sorted(arr)
	(a, b) = ([], [])
	x = -1
	for i in arr:
		if i != x:
			a.append(i)
			x = i
		else:
			b.append(i)
	(m, ma, mb) = (0, -1, -1)
	if a[0] == 0:
		for i in range(len(a) - 1):
			if a[i + 1] - a[i] > 1:
				ma = a[i] + 1
				break
		if ma == -1:
			ma = a[len(a) - 1] + 1
	else:
		ma = 0
	if len(b) == 0:
		mb = 0
	elif b[0] == 0:
		for i in range(len(b) - 1):
			if b[i + 1] - b[i] > 1:
				mb = b[i] + 1
				break
		if mb == -1:
			mb = b[len(b) - 1] + 1
	else:
		mb = 0
	m = ma + mb
	print(m)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ans1 = 0
	ans2 = 0
	m = max(arr) + 1
	arr.sort()
	s = set(arr)
	for i in arr:
		if ans1 == i:
			ans1 += 1
		elif ans2 == i:
			ans2 += 1
	print(ans2 + ans1)


import collections
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	v = collections.Counter(a)
	(c, d) = (0, 0)
	ans = n + 1
	for i in range(0, n + 1):
		if v[i] == 0:
			print(min(2 * i, ans + i))
			c = 1
			break
		elif v[i] == 1 and d == 0:
			ans = i
			d = 1
	if c == 0:
		print(ans + n + 1)


from collections import *
from heapq import *

def find(arr):
	for i in range(0, 102):
		if i not in arr:
			return i
t = int(input())
while t:
	t -= 1
	n = int(input())
	arr = [int(x) for x in input().split()]
	arr1 = set()
	arr2 = set()
	arr.sort()
	l = 0
	last = -1
	visit = [False for i in range(n)]
	for e in arr:
		if l == 0 or e - last == 1:
			arr1.add(e)
			visit[l] = True
			last = e
			l += 1
		elif e == last:
			l += 1
			continue
		else:
			break
	for i in range(n):
		if visit[i] == False:
			arr2.add(arr[i])
	print(find(arr1) + find(arr2))


import sys

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	n = int(input())
	arr = get_array()
	dic = {}
	m = max(arr)
	for i in range(0, m + 2):
		dic[i] = 0
	for i in arr:
		dic[i] += 1
	ans = 0
	flag = 0
	for i in dic.keys():
		if flag == 1 and dic[i] == 0:
			ans += i
			break
		if dic[i] == 0 and flag != 1:
			ans = i + i
			break
		elif dic[i] == 1 and flag != 1:
			flag = 1
			ans += i
	print(ans)


import sys
for _ in range(int(input())):
	n = int(sys.stdin.readline())
	arr = list(map(int, sys.stdin.readline().split()))
	arr.sort()
	ans = []
	for i in range(101):
		if i in arr:
			arr.remove(i)
		else:
			ans.append(i)
			break
	for i in range(101):
		if i in arr:
			arr.remove(i)
		else:
			ans.append(i)
			break
	print(sum(ans))


import math
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = [0 for i in range(101)]
	for i in range(n):
		b[a[i]] += 1
	sumi = 0
	f = 0
	for i in range(len(b)):
		if b[i] == 0 and f == 1:
			sumi += i
			f += 1
		elif b[i] == 0:
			sumi += 2 * i
			break
		elif b[i] == 1 and f == 0:
			sumi += i
			f += 1
		if f == 2:
			break
	print(sumi)


def mex(m):
	for i in range(len(m)):
		if i not in m:
			return i
	return len(m)
t = int(input())
res = []
for i in range(t):
	s = int(input())
	M = [int(x) for x in input().split()]
	if len(M) == max(M) + 1 == mex(M):
		res.append(max(M) + 1)
	if len(M) > mex(M):
		A = mex(M)
		for i in range(A):
			M.pop(M.index(i))
		res.append(A + mex(M))
for e in res:
	print(e)


import sys
sys.setrecursionlimit(2147483647)
input = sys.stdin.readline
from collections import defaultdict

def solve(t, A):
	d = defaultdict(int)
	for a in A:
		d[a] += 1
	index = 0
	while True:
		if d[index] > 0:
			d[index] -= 1
			index += 1
		else:
			a = index
			break
	index = 0
	while True:
		if d[index] > 0:
			d[index] -= 1
			index += 1
		else:
			b = index
			break
	return a + b

def main():
	n = int(input())
	ans = []
	for _ in range(n):
		t = int(input())
		ans.append(solve(t, list(map(int, input().split(' ')))))
	for r in ans:
		print(r)
main()


for _ in range(int(input())):
	x = []
	lsta = []
	lstb = []
	i = int(input())
	x = list(map(int, input().split()[:i]))
	x.sort()
	for j in x:
		if j not in lsta:
			lsta.append(j)
		else:
			lstb.append(j)
	a = max(lsta) + 2
	try:
		b = max(lstb) + 2
	except:
		b = 0
		val2 = 0
	for l in range(a):
		if l not in lsta:
			val1 = l
			break
	for m in range(b):
		if m not in lstb:
			val2 = m
			break
	print(val1 + val2)


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	i = 0
	while i in s:
		s.remove(i)
		i = i + 1
	j = 0
	while j in s:
		s.remove(j)
		j = j + 1
	print(i + j)


from sys import stdin, stdout
from collections import defaultdict, deque, Counter, OrderedDict

def Integer():
	return int(stdin.readline().strip())

def MapInteger():
	return map(int, stdin.readline().strip().split())

def MapList():
	return list(map(int, stdin.readline().split()))
for _ in range(int(input())):
	k = int(input())
	array = list(MapInteger())
	countnum = Counter(array)
	first = True
	second = True
	(a, b) = (0, 0)
	for i in range(max(array) + 1):
		if countnum[i] >= 2:
			if first:
				a += 1
			if second:
				b += 1
		if countnum[i] == 1:
			if first:
				a += 1
			if second:
				second = False
		if countnum[i] == 0:
			if first:
				first = False
			if second:
				second = False
	print(a + b)


from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	cnt = defaultdict(int)
	for i in a:
		cnt[i] += 1
	ans = 0
	for i in range(0, 101):
		if cnt[i] != 0:
			cnt[i] -= 1
		else:
			ans += i
			break
	for i in range(0, 101):
		if cnt[i] != 0:
			cnt[i] -= 1
		else:
			ans += i
			break
	print(ans)


from itertools import groupby

def main(inp):
	(a, b) = ([], [])
	while True:
		if len(inp) == 0:
			break
		if len(inp) == 1:
			a.append(inp[0])
			break
		if inp[0] != inp[1]:
			a.extend(inp)
			break
		else:
			(a.append(inp[0]), b.append(inp[1]))
			inp = inp[2:]
	a.extend([102, 103])
	b.extend([102, 103])
	return (a, b)

def mex(a):
	if a[0] != 0:
		return 0
	for i in range(len(a)):
		if a[i + 1] > a[i] + 1:
			mex = a[i] + 1
			return mex
testcases = int(input())
i = 0
for inp in range(testcases * 2):
	inp = input().split(' ')
	i += 1
	if i % 2 == 0:
		inp = [int(i) for i in inp]
		inp.sort()
		inp_s = [item for (item, group) in groupby(inp) for i in range(min(2, sum((1 for _ in group))))]
		(a, b) = main(inp_s)
		(a, b) = (mex(a), mex(b))
		print(str(a + b))


for t in range(int(input())):
	n = int(input())
	a = [int(j) for j in input().split()]
	a.sort()
	(A, B) = (set(), set())
	for x in a:
		if x in A:
			B.add(x)
		else:
			A.add(x)
	(i, j) = (0, 0)
	while i in A:
		i += 1
	while j in B:
		j += 1
	print(i + j)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	freq = 101 * [0]
	for i in l:
		freq[i] += 1
	ans = 0
	c = 0
	for i in range(101):
		if freq[i] < 2:
			ans += i
			break
	add = 0
	import bisect
	for i in range(102):
		j = bisect.bisect_left(l, i)
		if j == len(l) or l[bisect.bisect_left(l, i)] != i:
			add = i
			break
	print(ans + add)


n = int(input())

def mex(li):
	now = 0
	if not li:
		return 0
	while True:
		if now not in li:
			break
		now += 1
	return now
for _ in range(n):
	m = int(input())
	li = list(map(int, input().split()))
	li.sort()
	a = []
	b = []
	for i in li:
		if i in a:
			b.append(i)
		else:
			a.append(i)
	print(mex(a) + mex(b))


t = int(input())
i = 1
while i <= t:
	n = int(input())
	s = list(map(int, input().split()))
	j = 0
	flag = True
	one = False
	r = 0
	while flag:
		c = s.count(j)
		if c == 1 and one == False:
			r += j
			one = True
		elif c == 0:
			if one == True:
				r += j
				print(r)
			else:
				r += 2 * j
				print(r)
			break
		j += 1
	i += 1


def mex(a):
	mex = 0
	while mex in a:
		mex += 1
	return mex
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	summ = mex(a)
	for i in range(summ):
		if a.count(i) > 1:
			summ += 1
		else:
			break
	print(summ)


for _ in range(int(input())):
	input()
	arr = list(map(int, input().split(' ')))
	if arr.count(0) < 1:
		print(0)
	elif arr.count(0) == 1:
		b = 1
		while arr.count(b):
			b += 1
		print(b)
	else:
		A = list(set(arr))
		for i in A:
			arr.remove(i)
		B = arr
		b1 = 1
		while A.count(b1):
			b1 += 1
		b2 = 1
		while B.count(b2):
			b2 += 1
		print(b1 + b2)


for tc in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	a = []
	b = []
	prev = -1
	for i in arr:
		if i == prev:
			b.append(i)
		else:
			prev = i
			a.append(i)
	a = set(a)
	ini = 0
	for i in a:
		if i != ini:
			sa = ini
			break
		ini += 1
	else:
		sa = ini
	b = set(b)
	ini = 0
	for i in b:
		if i != ini:
			sb = ini
			break
		ini += 1
	else:
		sb = ini
	print(sa + sb)


t = int(input())
for z in range(t):
	n = int(input())
	a = list(map(int, input().split()))[:n]
	a.sort()
	if a[0] != 0:
		print(0)
		continue
	else:
		b = list()
		suma = 0
		a.pop(0)
		current = 0
		for i in range(len(a)):
			if a[i] - current == 1:
				current = a[i]
			else:
				b.append(a[i])
		suma = current + 1
		if len(b) != 0:
			if b[0] != 0:
				print(suma)
				continue
			else:
				current = 0
				for i in range(len(b)):
					if b[i] - current == 1:
						current = b[i]
					elif b[i] - current > 1:
						break
			suma = suma + current + 1
		print(suma)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	l = [0 for i in range(105)]
	for i in a:
		l[i] += 1
	s = 0
	mn = 2
	for i in range(105):
		if l[i] == 0:
			break
		if l[i] >= mn:
			s += mn
		elif l[i] < mn:
			mn = l[i]
			s += mn
	print(s)


import sys
rl = sys.stdin.readline
readInt = lambda : int(rl())
t = readInt()
for i in range(t):
	n = readInt()
	ns = [int(x) for x in rl().split()]
	nums = sorted(ns)
	(a, b) = (-1, -1)
	for n in nums:
		da = n - a
		if da == 1:
			a = n
			continue
		db = n - b
		if db == 1:
			b = n
			continue
	print(a + b + 2)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in range(0, 101):
		d[i] = 0
	for i in l:
		d[i] = d[i] + 1
	ans = 0
	for i in range(102):
		if d[i] <= 1:
			ans = ans + i
			break
	for i in range(102):
		if d[i] == 0:
			ans = ans + i
			break
	print(ans)


t = int(input())
for i in range(t):
	l = int(input())
	n = sorted(list(map(int, input().split())))
	(a, b) = (0, 0)
	for x in n:
		if a == x:
			a += 1
		elif b == x:
			b += 1
	print(a + b)


t = int(input())
for _ in range(t):
	n = int(input())
	N = list(map(int, input().split()))
	d = dict()
	for i in N:
		d[i] = d.get(i, 0) + 1
	s = list(set(N))
	s.sort()
	aa = 0
	bb = 0
	done = 0
	q = 0
	ans = 0
	while done < 2 and q < 101:
		if done == 0:
			if q not in s:
				ans = 2 * q
				done = 2
				q += 1
			elif d[q] == 1:
				ans += q
				done += 1
				q += 1
			else:
				q += 1
		elif done == 1:
			if q not in s:
				ans += q
				q += 1
				done += 1
			else:
				q += 1
	print(ans)


import sys
from collections import Counter
input = sys.stdin.readline

def solve(n, a):
	c = Counter(a)
	subseta = set()
	subsetb = set()
	for i in range(102):
		if c[i] >= 2:
			subseta.add(i)
			subsetb.add(i)
		elif c[i] == 1:
			subseta.add(i)
	mexa = mexb = 0
	for i in range(102):
		if i not in subseta:
			mexa = i
			break
	for i in range(102):
		if i not in subsetb:
			mexb = i
			break
	return mexa + mexb
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	v = solve(n, a)
	print(v)


from collections import *

def mex(L):
	L = set(L)
	ret = 0
	while ret in L:
		ret += 1
	return ret
for T in range(int(input())):
	n = int(input())
	L = list(sorted(map(int, input().split())))
	(A, B) = ([], [])
	A.append(L[0])
	for x in L[1:]:
		if x in A:
			B.append(x)
		else:
			A.append(x)
	print(mex(A) + mex(B))


test = int(input())
for t in range(test):
	n = int(input())
	l = list(map(int, input().split()))
	a = 0
	b = 0
	contains = [0 for i in range(101)]
	for i in l:
		contains[i] += 1
	for i in range(n + 1):
		if i in l:
			l.remove(i)
			continue
		else:
			a = i
			break
	for i in range(n + 1):
		if i in l:
			l.remove(i)
			continue
		else:
			b = i
			break
	print(a + b)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	dic = [0] * 102
	for i in l:
		dic[i] += 1
	(a, b) = (0, 0)
	k = 2
	for i in range(102):
		if dic[i] < 2:
			a = i
			break
	for i in range(102):
		if dic[i] < 1:
			b = i
			break
	print(a + b)


from collections import deque
from collections import OrderedDict
import math
import sys
import os
import threading
import bisect
import operator
import heapq
from atexit import register
from io import BytesIO
import io
from sys import stdin, stdout
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	ar.sort()
	set1 = set()
	set2 = set()
	for i in range(n):
		if ar[i] not in set1:
			set1.add(ar[i])
			ar[i] = -1
	for i in range(n):
		if ar[i] not in set2 and ar[i] != -1:
			set2.add(ar[i])
	max1 = 0
	max2 = 0
	idx = 0
	for i in set1:
		if i != idx:
			max1 = idx
			break
		idx += 1
	else:
		max1 = idx
	idx = 0
	for i in set2:
		if i != idx:
			max2 = idx
			break
		idx += 1
	else:
		max2 = idx
	print(max1 + max2)
sys.exit(0)
n = int(input())
lis = list(map(int, input().split()))
answer = 0
for i in range(n):
	answer += lis[i] - 1
if n == 1:
	print(n - 1)
elif n > 32:
	print(answer)
	sys.exit(0)
lis.sort()
for i in range(2, 50000):
	localMin = 0
	for j in range(n):
		needVal = i ** j
		localMin += abs(lis[j] - needVal)
		if localMin > answer:
			break
	else:
		answer = min(localMin, answer)
print(answer)
sys.exit(0)

class Person:

	def __init__(self, name, age):
		self.name = name
		self.age = age
p1 = Person('heelo', 27)
print(help(Person))
age = 26
name = 'Swaroop'
print('Возрас {} -- {} лет'.format(name, age))
print(help(object))


t = int(input())

def solve():
	n = int(input())
	a = [int(i) for i in input().split()]
	cou = [0 for i in range(120)]
	for i in range(n):
		cou[a[i]] += 1
	b = []
	c = []
	for i in range(120):
		if cou[i] == 0:
			break
		elif cou[i] == 1:
			b.append(i)
		else:
			b.append(i)
			c.append(i)
	ans1 = len(b)
	ans2 = len(c)
	b.sort()
	c.sort()
	for i in range(len(b)):
		if i != b[i]:
			ans1 = i
			break
	for i in range(len(c)):
		if i != c[i]:
			ans2 = i
			break
	print(ans1 + ans2)
while t:
	t -= 1
	solve()


def mex(l):
	i = 0
	while True:
		if i not in l:
			return i
		i += 1
for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	(i, zero) = (0, 'Not')
	(l1, l2) = (None, None)
	while i <= max(a):
		if a.count(i) == 1:
			l1 = [x for x in range(i) if x in a] + a[a.index(i):]
			l2 = [x for x in range(i) if x in a]
			break
		elif a.count(i) == 0:
			zero = i
			break
		i += 1
	if zero != 'Not':
		print(2 * zero)
	elif l1 == None and l2 == None:
		print((max(a) + 1) * 2)
	else:
		print(mex(set(l1)) + mex(set(l2)))


l = []

def mx(a):
	if len(a) == 0:
		return 0
	if a[0] != 0:
		return 0
	else:
		for i in range(1, len(a)):
			if a[i] - a[i - 1] > 1:
				return a[i - 1] + 1
	return a[-1] + 1
for i in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	b = []
	a = [s[0]]
	j = 0
	for i in range(1, n):
		if s[i] == a[j]:
			b.append(s[i])
		else:
			a.append(s[i])
			j = j + 1
	l.append(mx(a) + mx(b))
for i in l:
	print(i)


from sys import stdin, stdout
from collections import Counter
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	ans = 0
	a = list(map(int, stdin.readline().split()))
	d = Counter(a)
	sa = set()
	sb = set()
	dont = 1
	for v in range(101):
		if d[v] == 1:
			sa.add(v)
			dont = 0
		elif d[v] >= 2:
			sa.add(v)
			if dont:
				sb.add(v)
		else:
			break
	if sa:
		ans += max(sa) + 1
	if sb:
		ans += max(sb) + 1
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	lst = sorted([int(x) for x in input().split()])
	(m1, m2) = (0, 0)
	taken = list()
	for i in range(n):
		if lst[i] == m1:
			m1 += 1
			taken.append(i)
	for i in range(n):
		if i in taken:
			continue
		if lst[i] == m2:
			m2 += 1
	sol = m1 + m2
	print(sol)


from sys import stdin, stdout

def INPUT():
	return list((int(i) for i in stdin.readline().split()))

def inp():
	return stdin.readline()

def out(x):
	return stdout.write(x)
import math
import random
import sys
for _ in range(int(input())):
	n = int(input())
	A = INPUT()
	F = [0] * 101
	for i in range(n):
		F[A[i]] += 1
	i = 0
	while F[i] > 0:
		i += 1
	first = i
	j = 0
	while F[j] != 1 and F[j] != 0:
		j += 1
	second = j
	print(first + second)


import sys

def inpt():
	return sys.stdin.readline().rstrip()

def read():
	return [int(x) for x in inpt().split()]

def mex(a):
	for i in range(107):
		if i not in a:
			return i
(_T_,) = read()
for _t_ in range(_T_):
	(n,) = read()
	ar = read()
	a = set()
	b = set()
	vis = set()
	for i in ar:
		if i not in vis:
			vis.add(i)
			a.add(i)
		else:
			b.add(i)
	print(mex(a) + mex(b))


def solve(arr, n):
	i = 0
	mexA = 0
	mexB = 0
	b = False
	while True:
		temp = arr.count(i)
		if temp >= 2:
			i += 1
			continue
		if b == False and temp == 1:
			mexB = i
			b = True
			i += 1
			continue
		if b == True and temp == 1:
			i += 1
			continue
		if temp == 0:
			mexA = i
			if b == False:
				mexB = i
			break
	return mexA + mexB
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	print(solve(arr, n))


from collections import Counter
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = [int(i) for i in input().split()]
	if 0 not in a:
		print(0)
	else:
		l = list(dict.fromkeys(a))
		(x, y) = (0, 0)
		(x1, y1) = (True, True)
		for i in l:
			a.remove(i)
		for i in range(101):
			if i not in l and x1:
				x = i
				x1 = False
			if i not in a and y1:
				y = i
				y1 = False
			if x1 == False and y1 == False:
				break
		print(x + y)


def mex(list):
	temp = 0
	for i in list:
		if i < temp:
			continue
		elif i == temp:
			temp += 1
		else:
			break
	return temp
n = int(input())
for i in range(n):
	m = int(input())
	mylist = [int(p) for p in input().split()]
	mylist.sort()
	list1 = []
	list2 = []
	list1.append(mylist[0])
	k = 1
	while k < len(mylist):
		if mylist[k] == mylist[k - 1]:
			flag = 1
		if mylist[k] == mylist[k - 1] + 1:
			list1.append(mylist[k])
		else:
			list2.append(mylist[k])
		k += 1
	if len(list2) == 0:
		print(mex(list1))
	else:
		print(mex(list1) + mex(list2))


t = int(input())
while t > 0:
	n = int(input())
	counts = [0] * 101
	elems = list(map(int, input().split()))
	for elem in elems:
		counts[elem] += 1
	i = 0
	sum = 0
	flag = 0
	while i <= 100:
		if counts[i] == 0:
			print(sum)
			break
		if counts[i] == 1:
			sum += 1
			flag = 1
		elif counts[i] >= 2 and i != 0:
			if flag == 0:
				sum += 2
			else:
				sum += 1
		elif counts[i] >= 2:
			sum += 2
		i += 1
	t -= 1


from sys import stdin
import math
inp = lambda : stdin.readline().strip()
t = int(inp())
for _ in range(t):
	n = int(inp())
	a = [int(x) for x in inp().split()]
	a.sort()
	ans = 0
	twos = True
	ones = True
	c = 0
	while True:
		if a.count(c) < 2 and twos:
			ans += c
			twos = False
		if a.count(c) < 1 and ones:
			ans += c
			ones = False
		if twos == False and ones == False:
			break
		c += 1
	print(ans)


from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	d = Counter(l)
	A = []
	B = []
	for i in d.keys():
		if d[i] >= 2:
			A.append(i)
			B.append(i)
		else:
			A.append(i)
	Ar = list(range(0, len(A)))
	Br = list(range(0, len(B)))
	s = 0
	flag1 = 0
	flag2 = 0
	for i in range(max(len(Ar), len(Br))):
		if i < len(Ar) and flag1 == 0 and (Ar[i] != A[i]):
			flag1 = 1
			s += Ar[i]
		if i < len(Br) and flag2 == 0 and (Br[i] != B[i]):
			flag2 = 1
			s += Br[i]
		if flag1 == 1 and flag2 == 1:
			break
	if flag1 == 0:
		s += len(Ar)
	if flag2 == 0:
		s += len(Br)
	print(s)


k = int(input())
while k > 0:
	l = [0] * 101
	n = int(input())
	ml = list(map(int, input().split()))
	for i in ml:
		l[i] += 1
	sumi = 0
	for i in range(0, 101):
		if l[i] == 0:
			sumi += i
			break
	for i in range(0, 101):
		if l[i] <= 1:
			sumi += i
			break
	k -= 1
	print(sumi)


for _ in range(int(input())):
	n = int(input())
	al = list(map(int, input().split()))
	al.sort()
	cntl = []
	prev = al[0]
	cnt = 1
	for a in al[1:]:
		if prev == a:
			cnt += 1
		else:
			cntl.append((prev, cnt))
			cnt = 1
			prev = a
	cntl.append((prev, cnt))
	one_end = False
	ans1 = -1
	ans2 = -1
	for (i, (a, cnt)) in enumerate(cntl):
		if a == i:
			if cnt >= 2:
				pass
			elif not one_end:
				ans1 = i
				one_end = True
			else:
				pass
		else:
			if ans1 == -1:
				ans1 = i
			ans2 = i
			break
	else:
		if ans1 == -1:
			ans1 = max(al) + 1
		if ans2 == -1:
			ans2 = max(al) + 1
	print(ans1 + ans2)


for i in range(int(input())):
	j = int(input())
	k = list(map(int, input().split()))
	a = []
	b = []
	for l in k:
		if l in a:
			b.append(l)
		else:
			a.append(l)
	ai = 0
	bi = 0
	for l in range(len(a) + 1):
		if l in a:
			continue
		ai = l
		break
	for l in range(len(b) + 1):
		if l in b:
			continue
		bi = l
		break
	print(ai + bi)


from __future__ import division, print_function
from sys import stdin, stdout
import bisect
import math
import heapq
i_m = 9223372036854775807

def inin():
	return int(input())

def stin():
	return input()

def spin():
	return map(int, stin().split())

def lin():
	return list(map(int, stin().split()))

def matrix(n):
	return [list(map(int, input().split())) for i in range(n)]

def count2Dmatrix(i, list):
	return sum((c.count(i) for c in list))

def modinv(n, p):
	return pow(n, p - 2, p)

def GCD(x, y):
	x = abs(x)
	y = abs(y)
	if min(x, y) == 0:
		return max(x, y)
	while y:
		(x, y) = (y, x % y)
	return x

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l
prime = []

def SieveOfEratosthenes(n):
	global prime
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	f = []
	for p in range(2, n):
		if prime[p]:
			f.append(p)
	return f
q = []

def dfs(n, d, v, c):
	global q
	v[n] = 1
	x = d[n]
	q.append(n)
	j = c
	for i in x:
		if i not in v:
			f = dfs(i, d, v, c + 1)
			j = max(j, f)
	return j
for _ in range(inin()):
	n = inin()
	a = lin()
	a.sort()
	(x, y) = (0, 0)
	for i in a:
		if x == i:
			x += 1
		elif y == i:
			y += 1
	print(x + y)


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	u = 0
	for i in range(n + 1):
		if a.count(i) < 2:
			u = i
			break
	v = 0
	for i in range(n + 1):
		if a.count(i) < 1:
			v = i
			break
	print(u + v)
t = int(input())
for _ in range(t):
	solve()


def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	a = b = None
	count = {}
	for val in arr:
		if val in count:
			count[val] += 1
		else:
			count[val] = 1
	req = 2
	for i in range(max(arr) + 2):
		if i not in count:
			if a is None:
				a = i
			if b is None:
				b = i
				break
		elif count[i] >= req:
			pass
		else:
			a = i
			req = 1
	print(a + b)
for _ in range(int(input())):
	solve()


t = int(input())
ans = []
while t > 0:
	t -= 1
	flag = 0
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	if a.count(0) == 0:
		print(0)
	else:
		am = []
		bm = []
		for i in a:
			if i not in am:
				am.append(i)
			if a.count(i) > 1 and i not in bm:
				bm.append(i)
		for i in list(range(101)):
			if i not in am:
				amax = i
				break
		for i in list(range(101)):
			if i not in bm:
				bmax = i
				break
		print(amax + bmax)


import sys
t = int(input())
for i in range(t):
	counter = {}
	n = int(input())
	A = list(map(int, input().strip().split(' ')))
	for a in A:
		if a not in counter:
			counter[a] = 1
		else:
			counter[a] += 1
	ans = 0
	for i in range(101):
		if i not in counter:
			ans += i
			break
	for i in range(101):
		x = counter.get(i)
		if x is None or x == 1:
			ans += i
			break
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	b = [0] * 105
	for i in range(n):
		b[a[i]] += 1
	c = 0
	for i in range(len(b)):
		if b[i] > 0:
			b[i] -= 1
		else:
			c += i
			break
	for i in range(len(b)):
		if b[i] > 0:
			b[i] -= 1
		else:
			c += i
			break
	print(c)


class Node:

	def __init__(self, val):
		self.val = val
		self.children = None
		self.centroid = None
		self.edges = []

class Graph:

	def __init__(self):
		self.root = None

	def add_edge(self, a, b):
		if self.root == None:
			self.root = a
		a.edges.append(b)
		b.edges.append(a)

def dfs_children(g, root, visited):
	visited.add(root.val)
	c = 0
	for i in root.edges:
		if i.val not in visited:
			visited.add(i.val)
			c += 1 + dfs_children(g, i, visited)
	root.children = c
	return root.children

def dfs_centroids(g, root, visited, n, ce):
	visited.add(root.val)
	c = -1
	t = 0
	for i in root.edges:
		if i.val not in visited:
			visited.add(i.val)
			c = max(c, i.children + 1)
			dfs_centroids(g, i, visited, n, ce)
			t += i.children + 1
	c = max(c, n - t - 1)
	root.centroid = c
	if c in ce:
		ce[c].append(root)
	else:
		ce[c] = [root]
	return root.centroid

def get_leaf(root, li, visited, noti):
	if root.val == noti.val:
		return False
	visited.add(root.val)
	flag = True
	for i in root.edges:
		if i.val not in visited and i.val != noti.val:
			visited.add(i.val)
			li[0] = root
			li[1] = i
			flag = flag & get_leaf(root, li, visited, noti)
	return flag

def process():
	n = int(input())
	li = list(map(int, input().split()))
	counts = {}
	for i in li:
		if i in counts:
			counts[i] += 1
		else:
			counts[i] = 1
	ans = -1
	for i in range(0, 101):
		if i in counts:
			if counts[i] >= 2:
				pass
			elif counts[i] == 1 and ans == -1:
				ans = 0
				ans += i
		elif ans >= 0:
			ans += i
			break
		else:
			ans = 2 * i
			break
	print(ans)
tests = int(input())
for i in range(tests):
	process()


import sys
read = lambda : sys.stdin.readline().strip()
readi = lambda : map(int, read().split())
from collections import defaultdict
for _ in range(int(read())):
	n = int(read())
	nums = list(readi())
	counts = defaultdict(int)
	m = -1
	for i in nums:
		counts[i] += 1
		m = max(m, i)
	ans1 = ans2 = 0
	stop2 = False
	for i in range(m + 1):
		if i in counts:
			if counts[i] > 1:
				ans1 += 1
				if not stop2:
					ans2 += 1
			else:
				stop2 = True
				ans1 += 1
		else:
			break
	print(ans1 + ans2)


import sys
LI = lambda : list(map(int, sys.stdin.readline().strip('\n').split()))
MI = lambda : map(int, sys.stdin.readline().strip('\n').split())
SI = lambda : sys.stdin.readline().strip('\n')
II = lambda : int(sys.stdin.readline().strip('\n'))
for _ in range(II()):
	n = II()
	cnt = [0] * 101
	for i in MI():
		cnt[i] += 1
	(a, b) = (-1, -1)
	for i in range(101):
		if cnt[i] == 0:
			if a == -1:
				a = b = i
			else:
				b = i
			break
		if cnt[i] == 1:
			if a == -1:
				a = i
	print(a + b)


def mex(a):
	a_s = list(set(a))
	a_s.sort()
	for i in range(len(a_s)):
		if i != a_s[i]:
			return i
	return len(a_s)
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	if 0 not in arr:
		print(0)
	elif arr.count(0) == 1:
		print(mex(arr))
	else:
		a = mex(arr)
		for i in range(a):
			arr.remove(i)
		b = mex(arr)
		print(a + b)


for _ in range(int(input())):
	n = int(input())
	a = [0] * 101
	arr = list(map(int, input().split()))
	for x in arr:
		a[int(x)] += 1
	i = a.index(0)
	a[i] = 1
	print(i + a.index(1))


def algo(n, arr):
	arr.sort()
	temp = [0 for _ in range(arr[-1] + 1)]
	for i in range(n):
		temp[arr[i]] += 1
	t1 = 0
	for i in range(len(temp)):
		if temp[i] == 0:
			t1 = i
			break
	else:
		t1 = len(temp)
	t2 = 0
	for i in range(len(temp)):
		if temp[i] < 2:
			t2 = i
			break
	else:
		t2 = len(temp)
	return t1 + t2
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = algo(n, arr)
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	c = []
	x = input().split(' ')
	for i in x:
		c.append(int(i))
	c.sort()
	a = []
	b = []
	for i in c:
		if i not in a:
			a.append(i)
		else:
			b.append(i)
	mex1 = 0
	mex2 = 0
	for i in range(101):
		if i not in a:
			mex1 = i
			break
	for i in range(101):
		if i not in b:
			mex2 = i
			break
	print(mex1 + mex2)


import os
import sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split(' ')))
		ma = 0
		for x in range(0, 200):
			if x in a:
				ma = x + 1
				a.remove(x)
			else:
				break
		mb = 0
		for x in range(0, 200):
			if x in a:
				a.remove(x)
				mb = x + 1
			else:
				break
		print(ma + mb)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	s = set(l)
	a = 0
	b = []
	for i in s:
		if i == a:
			b.append(i)
		else:
			break
		a += 1
	if 0 not in b:
		print('0')
	else:
		m = 0
		for i in s:
			if l.count(i) - 1 > 0 and i == m:
				m += 1
				continue
			else:
				break
		print(max(b) + 1 + m)


from functools import lru_cache
from sys import stdin, stdout
import sys
from math import *
input = stdin.readline
for __ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	ar.sort()
	d = {}
	for i in range(n):
		if d.get(ar[i]) == None:
			d[ar[i]] = 0
		d[ar[i]] += 1
	x = 0
	y = 0
	for i in range(101):
		if d.get(i) == None:
			x = i
			break
	for i in range(101):
		if d.get(i) == None or d.get(i) == 1:
			y = i
			break
	print(x + y)


import sys
from collections import Counter
t = int(sys.stdin.readline())
for _ in range(t):
	n = int(sys.stdin.readline())
	A = Counter(map(int, sys.stdin.readline().split()))
	ans = 0
	for _ in range(2):
		for i in range(n):
			if A[i] == 0:
				break
			A[i] -= 1
			ans += 1
	print(ans)


def ans():
	n = int(input())
	lst = map(lambda x: int(x), input().split(' '))
	(a, b) = ([], [])
	for num in lst:
		if num in a:
			b.append(num)
		else:
			a.append(num)
	print(mex(a) + mex(b))

def mex(lst):
	for i in range(101):
		if i not in lst:
			return i

def main():
	t = int(input())
	while t:
		ans()
		t -= 1
main()


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	h = {}
	for i in s:
		if i not in h:
			h[i] = 0
		h[i] += 1
	for i in range(102):
		if i not in h:
			h[i] = 0
	out = 0
	for i in range(102):
		if h[i] == 0:
			out = i
			break
	temp = 1
	for i in range(102):
		if h[i] == 1 and i < out:
			out += i
			temp = 0
			break
	if temp == 0:
		print(out)
	else:
		print(2 * out)


for i in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	A = sorted(A)
	cnt = 0
	MexA = []
	ans = 0
	while cnt in A:
		A.remove(cnt)
		MexA.append(cnt)
		cnt += 1
	cnt = 0
	while cnt in A:
		ans += 1
		cnt += 1
	cnt = 0
	for k in MexA:
		if k == cnt:
			ans += 1
			cnt += 1
		else:
			break
	print(ans)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	data = [0] * 101
	for i in range(n):
		data[a[i]] += 1
	M = -1
	m = -1
	for i in range(101):
		if data[i] <= 1:
			m = i
			break
	for i in range(101):
		if data[i] == 0:
			M = i
			break
	print(m + M)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = {}
	for i in range(n):
		if a[i] in b:
			b[a[i]] += 1
		else:
			b[a[i]] = 1
	c = sorted(b.items(), key=lambda x: x[0])
	r = 0
	t = 0
	for i in range(len(c)):
		(u, v) = c[i]
		if u == i and v == 1 and (t == 0):
			r += u
			t += 1
		elif u != i and t == 0:
			r += 2 * i
			t += 2
		elif u != i and t == 1:
			r += i
			t += 1
		if t == 2:
			break
	if t == 1:
		r += c[-1][0] + 1
	elif t == 0:
		r += (c[-1][0] + 1) * 2
	print(r)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input().split()
	nums = list(map(int, s))
	nums.sort()
	mex_a = 0
	mex_b = 0
	mex = 0
	i = 0
	while i < n:
		if nums[i] == mex:
			temp = 0
			while i < n and nums[i] == mex:
				temp += 1
				i += 1
			if temp >= 2:
				mex += 1
			else:
				i -= 1
				break
		else:
			break
	mex_a = mex
	for j in range(i, n):
		if nums[j] > mex_a:
			break
		elif nums[j] == mex_a:
			mex_a += 1
	print(mex_a + mex)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	(num1, num2) = ([l[0]], [])
	for i in range(1, n):
		if l[i] == l[i - 1]:
			num2.append(l[i])
		else:
			num1.append(l[i])
	(m1, m2) = (0, 0)
	for i in num1:
		if i == m1:
			m1 += 1
	for i in num2:
		if i == m2:
			m2 += 1
	print(m1 + m2)


import sys
inp = sys.stdin.buffer.readline
inar = lambda : list(map(int, inp().split()))
inin = lambda : int(inp())
inst = lambda : inp().decode().rstrip('\n\r')

def mex(a):
	for i in range(107):
		if i not in a:
			return i
_T_ = inin()
for _t_ in range(_T_):
	n = inin()
	ar = inar()
	a = set()
	b = set()
	vis = set()
	for i in ar:
		if i not in vis:
			vis.add(i)
			a.add(i)
		else:
			b.add(i)
	print(mex(a) + mex(b))


from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	hash = defaultdict(int)
	for i in l:
		hash[i] += 1
	mexa = 0
	mexb = 0
	flag = 0
	for i in range(n + 1):
		if i in hash:
			if hash[i] == 1:
				mexa += 1
				flag = 1
			else:
				mexa += 1
				if flag != 1:
					mexb += 1
		else:
			break
	print(mexa + mexb)


import sys, collections as cc
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(t,) = I()
for _ in range(t):
	(n,) = I()
	l = I()
	an = cc.Counter(l)
	a = b = 0
	f = 1
	for i in range(n):
		if f:
			if an[i] > 1:
				a += 1
				b += 1
			elif an[i]:
				a += 1
				f = 0
			else:
				break
		elif an[i]:
			a += 1
		else:
			break
	print(a + b)


t = int(input())
for i in range(t):
	n = int(input())
	list1 = list(map(int, input().split()))
	list1.sort()
	dict1 = {}
	dict2 = {}
	for j in range(n):
		if list1[j] in dict1:
			if dict1[list1[j]] == 1 and list1[j] not in dict2:
				dict2[list1[j]] = 1
			else:
				dict1[list1[j]] += 1
		else:
			dict1[list1[j]] = 1
	b = list1[-1]
	for j in range(b + 2):
		if j not in dict1:
			c = j
			break
		else:
			continue
	for j in range(b + 2):
		if j not in dict2:
			d = j
			break
		else:
			continue
	print(c + d)


import math
from decimal import *
import random
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	mrk = [1] * n
	ans = 0
	for i in range(101):
		if i in arr:
			pos = arr.index(i)
			arr.pop(pos)
		else:
			ans += i
			break
	for i in range(101):
		if i in arr:
			pos = arr.index(i)
			arr.pop(pos)
		else:
			ans += i
			break
	print(ans)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	kls = [0] * 101
	for i in arr:
		kls[i] += 1
	s1 = 0
	s2 = 0
	flag = 0
	for i in range(101):
		if kls[i] >= 2:
			s1 += 1
			if flag == 0:
				s2 += 1
		elif kls[i] == 1:
			s1 += 1
			flag = 1
		else:
			break
	print(s1 + s2)


import sys

def input():
	return sys.stdin.readline().strip()

def mapint():
	return map(int, input().split())
sys.setrecursionlimit(10 ** 9)
T = int(input())
for _ in range(T):
	N = int(input())
	Xs = list(mapint())
	Xs.sort()
	x1 = 0
	for i in range(100):
		if i in Xs:
			x1 += 1
			Xs.remove(i)
		else:
			break
	x2 = 0
	for i in range(100):
		if i in Xs:
			x2 += 1
			Xs.remove(i)
		else:
			break
	print(x1 + x2)


from collections import Counter
for _ in range(int(input())):
	input()
	arr = map(int, input().split())
	c = Counter(arr)
	one = two = 0
	while 1:
		if c[two] >= 2:
			two += 1
		else:
			break
	one = two
	while 1:
		if c[one] >= 1:
			one += 1
		else:
			break
	print(two + one)


import sys
import math
from collections import Counter
input = sys.stdin.readline

def solve():
	n = int(input())
	L = list(map(int, input().split()))
	val = max(L)
	for i in range(val):
		if i not in L:
			a = i
			break
	else:
		a = val + 1
	li = []
	C = dict(Counter(L))
	for i in C:
		if C[i] > 1:
			li.append(i)
	if li == []:
		print(a)
		return
	else:
		val = max(li)
		for i in range(val):
			if i not in li:
				b = i
				break
		else:
			b = val + 1
	print(a + b)
for _ in range(int(input())):
	solve()


from math import *
from collections import *
from itertools import *
from functools import *
from bisect import *
from heapq import *
from operator import *
from sys import *
setrecursionlimit(100000000)
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	c = Counter(l)
	ans = 0
	f = 0
	(c1, c2) = (0, 0)
	for x in range(101):
		if c[x] == 0:
			break
		elif c[x] == 1:
			c1 += 1
			f = 1
		else:
			c1 += 1
			if not f:
				c2 += 1
	print(c1 + c2)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l = sorted(l)
	prev = -1
	v = [0] * 102
	for i in range(n):
		v[l[i]] += 1
	am = 2
	ans = 0
	for i in range(102):
		if v[i] < am:
			ans += (am - v[i]) * i
			am = v[i]
	print(ans)


import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import Counter

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		a = [ea for ea in a if ea >= 0]
		a.sort()
		if a[0] >= 1:
			print(0)
		else:
			ac = Counter(a)
			r1 = 0
			r2 = 0
			cnt = 0
			flag = False
			for (k, v) in ac.items():
				if k != cnt:
					break
				if v <= 1:
					r1 = cnt + 1
					flag = True
				elif flag:
					r1 = cnt + 1
				else:
					r1 = cnt + 1
					r2 = cnt + 1
				cnt += 1
			print(r1 + r2)
main()


t = int(input())
for T in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	first = 0
	second = 0
	amin = min(a)
	amax = max(a)
	if amin != 0:
		print(0)
		continue
	else:
		flag = 0
		another_flag = 0
		for i in range(102):
			if i not in a:
				first = i
				break
		for i in range(102):
			if a.count(i) <= 1:
				second = i
				break
		print(first + second)


import sys, math
import io, os
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter

def data():
	return sys.stdin.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
from decimal import Decimal
mod = int(1000000000.0) + 7
INF = 100000
for t in range(int(data())):
	n = int(data())
	a = mdata()
	d = dd(int)
	for i in a:
		d[i] += 1
	(ans1, ans2) = (INF, 0)
	for i in range(max(a) + 2):
		if d[i] == 1:
			ans1 = min(ans1, i)
		elif d[i] == 0:
			ans1 = min(ans1, i)
			ans2 = i
			break
	out(ans1 + ans2)


n = int(input())
for _ in range(n):
	k = int(input())
	a = list(map(int, input().split(' ')))
	a.sort()
	r = []
	l = []
	for i in a[:]:
		if a.count(i) == 1 and i not in r[:]:
			r.append(i)
		elif a.count(i) >= 2 and i not in r[:]:
			r.append(i)
			l.append(i)
	for i in range(101):
		if i not in r[:]:
			q = i
			break
	for i in range(101):
		if i not in l[:]:
			w = i
			break
	print(q + w)


for _ in range(int(input())):
	n = int(input())
	arr = [int(num) for num in input().split(' ')]
	arr.sort()
	a = [arr[0]]
	b = []
	for i in range(1, n):
		if arr[i] == arr[i - 1] + 1:
			a.append(arr[i])
		else:
			b.append(arr[i])
	ans = 0
	for i in range(a[-1] + 2):
		if a.count(i) == 0:
			ans = ans + i
			break
	if len(b) > 0:
		for i in range(b[-1] + 2):
			if b.count(i) == 0:
				ans = ans + i
				break
	print(ans)


for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	li.sort()
	tmp1 = []
	tmp2 = []
	i = 0
	res1 = -1
	res2 = -1
	while i < n:
		if i + 1 < n and li[i] == li[i + 1]:
			tmp1.append(li[i])
			tmp2.append(li[i + 1])
			i += 2
		else:
			tmp1.append(li[i])
			i += 1
	tmp1 = list(set(tmp1))
	tmp2 = list(set(tmp2))
	for i in range(len(tmp1)):
		if tmp1[i] != i:
			res1 = i
			break
	if res1 == -1:
		res1 = len(tmp1)
	for j in range(len(tmp2)):
		if tmp2[j] != j:
			res2 = j
			break
	if res2 == -1:
		res2 = len(tmp2)
	print(res1 + res2)


from functools import reduce
import os
import sys
from collections import *
from math import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def arr():
	return [int(i) for i in input().split()]

def sarr():
	return [int(i) for i in input()]

def starr():
	return [str(x) for x in input().split()]

def inn():
	return int(input())

def svalue():
	return tuple(map(str, input().split()))

def parr():
	return [value() for i in range(n)]
mo = 1000000007
for _ in range(inn()):
	n = inn()
	a = arr()
	d = defaultdict(int)
	for i in a:
		d[i] += 1
	flag = 0
	ans = 0
	for i in range(105):
		if flag == 0:
			if d[i] == 0:
				ans += 2 * i
				break
			elif d[i] == 1:
				ans += i
				flag = 1
		elif d[i] == 0:
			ans += i
			break
	print(ans)


for j in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = [0] * 101
	for x in a:
		d[x] += 1
	t = 0
	s = 2
	for i in range(102):
		if s == 0:
			break
		if s == 2 and d[i] < 2:
			t += i
			s = 1
		if s == 1 and d[i] < 1:
			s = 0
			t += i
	print(t)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))[:n]
	a.sort()
	x = []
	y = []
	x1 = []
	y1 = []
	for i in range(n):
		if i % 2 == 0:
			x.append(a[i])
		else:
			y.append(a[i])
	for i in range(0, 101):
		if i not in x:
			c = i
			break
	for i in range(0, 101):
		if i not in y:
			d = i
			break
	for i in range(0, 101):
		if i not in a:
			z = i
			break
	for i in range(n):
		if x1.count(a[i]) == 0:
			x1.append(a[i])
		else:
			y1.append(a[i])
	for i in range(0, 101):
		if i not in x1:
			c1 = i
			break
	for i in range(0, 101):
		if i not in y1:
			d1 = i
			break
	print(max(c + d, z, c1 + d1))


import sys

def Ints():
	return map(int, sys.stdin.readline().strip().split())

def Strs():
	return map(str, sys.stdin.readline().strip().split())

def Array():
	return list(map(int, sys.stdin.readline().strip().split()))

def Str():
	return sys.stdin.readline().strip()

def Int():
	return int(sys.stdin.readline().strip())

def MOD():
	return 1000000007
t = Int()
while t:
	t -= 1
	n = Int()
	arr = Array()
	maps = {}
	for i in arr:
		maps[i] = maps.get(i, 0) + 1
	ans = 0
	for i in range(max(arr) + 2):
		if i not in maps:
			ans += i
			break
		if i in maps and maps[i] > 0:
			maps[i] -= 1
	for i in range(max(arr) + 2):
		if i not in maps:
			ans += i
			break
		elif maps[i] == 0:
			ans += i
			break
		if i in maps and maps[i] > 0:
			maps[i] -= 1
	print(ans)


from __future__ import division, print_function
import os, sys
import math
import collections
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

class my_dictionary(dict):

	def __init__(self):
		self = dict()

	def add(self, key, value):
		self[key] = value

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def sli():
	return list(msi())

def dmain():
	sys.setrecursionlimit(100000000)
	threading.stack_size(40960000)
	thread = threading.Thread(target=main)
	thread.start()
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[1]

def sort2(l):
	return sorted(l, key=getKey, reverse=True)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def factorial(n):
	return 1 if n == 1 or n == 0 else n * factorial(n - 1)

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(n - r))

def binary_search(arr, low, high, x):
	if high >= low:
		mid = (high + low) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] > x:
			return binary_search(arr, low, mid - 1, x)
		else:
			return binary_search(arr, mid + 1, high, x)
	else:
		return -1

def ceil(x, y):
	if x % y == 0:
		return x // y
	else:
		return x // y + 1

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def nCr(n, r):
	return fact(n) / (fact(r) * fact(n - r))

def fact(n):
	res = 1
	for i in range(2, n + 1):
		res = res * i
	return res

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def padded_bin_with_complement(x):
	if x < 0:
		return bin(2 ** 16 - abs(x))[2:].zfill(16)
	else:
		return bin(x)[2:].zfill(16)

def binaryToDecimal(binary):
	binary1 = binary
	(decimal, i, n) = (0, 0, 0)
	while binary != 0:
		dec = binary % 10
		decimal = decimal + dec * pow(2, i)
		binary = binary // 10
		i += 1
	print(decimal)

def CountFrequency(my_list):
	freq = {}
	for item in my_list:
		if item in freq:
			freq[item] += 1
		else:
			freq[item] = 1
	return freq

def pos(a):
	b = [0] * len(a)
	c = sorted(a)
	for i in range(len(a)):
		for j in range(len(a)):
			if c[j] == a[i]:
				b[i] = j
				break
	return b

def smallestDivisor(n):
	if n % 2 == 0:
		return 2
	i = 3
	while i * i <= n:
		if n % i == 0:
			return i
		i += 2
	return n

def commonn(a, b, n):
	c = []
	for i in range(n):
		if a[i] == b[i]:
			c.append('-1')
		else:
			c.append(b[i])
	return c

def find_lcm(num1, num2):
	if num1 > num2:
		num = num1
		den = num2
	else:
		num = num2
		den = num1
	rem = num % den
	while rem != 0:
		num = den
		den = rem
		rem = num % den
	gcd = den
	lcm = int(int(num1 * num2) / int(gcd))
	return lcm

def sumdigit(n):
	n = str(n)
	k = 0
	for i in range(len(n)):
		k += int(n[i])
	return k

def main():
	for _ in range(ii()):
		n = ii()
		a = li()
		b = [0] * 105
		res = 0
		for i in range(n):
			b[a[i]] += 1
		count = 0
		f1 = f2 = 1
		first = 0
		sec = 0
		for i in range(len(b)):
			if b[i] > 1:
				if f1:
					first += 1
				if f2:
					sec += 1
			elif b[i] == 1:
				first += 1
				f2 = 0
			else:
				break
		print(sec + first)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from collections import Counter
T = int(input())
for t in range(T):
	_ = input()
	a = [int(x) for x in input().split()]
	a.sort()
	freq = Counter(a)
	onerun = -1
	tworun = -1
	for c in range(0, a[-1] + 1):
		if freq[c] == 1:
			onerun = c
		elif freq[c] >= 2:
			if tworun == c - 1:
				tworun = c
			onerun = c
		else:
			break
	print(onerun + 1 + tworun + 1)


import sys
from decimal import Decimal
from collections import defaultdict as dc
import math
from bisect import bisect_left, bisect_right
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	x = dc(int)
	y = dc(int)
	for i in l:
		if x[i] == 0:
			x[i] += 1
		elif y[i] == 0:
			y[i] += 1
	s = 0
	for i in range(101):
		if x[i] == 0:
			s += i
			break
	for i in range(101):
		if y[i] == 0:
			s += i
			break
	print(s)


def mex(l):
	for i in range(len(l) + 1):
		if i not in l:
			return i
	else:
		return 0
T = int(input())
for t in range(T):
	n = int(input())
	l = list(map(int, input().split()))
	A = []
	for i in range(len(l) + 1):
		if i in l:
			A.append(i)
			l.remove(i)
		else:
			break
	print(len(A) + mex(l))


def get_mex(a):
	a = sorted(list(set(a)))
	if not a or a[0] != 0:
		return 0
	mex = 0
	for i in a:
		if i == mex:
			mex = i + 1
		else:
			break
	return mex
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	a_ = []
	b_ = []
	for i in a:
		if not a_ or a_[-1] + 1 == i:
			a_.append(i)
		else:
			b_.append(i)
	print(get_mex(a_) + get_mex(b_))


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	p = {}
	ans = 0
	for i in range(101):
		p[i] = arr.count(i)
	for k in p:
		if p[k] == 0:
			ans += k
			break
	for k in p:
		if p[k] < 2:
			ans += k
			break
	print(ans)


for _ in range(int(input())):
	N = int(input())
	array = [int(x) for x in input().split()]
	checklist = [0 for i in range(200)]
	total = 0
	for i in array:
		checklist[i] += 1
	for i in range(2):
		j = 0
		while checklist[j]:
			checklist[j] -= 1
			j += 1
		total += j
	print(total)


from sys import stdin
input = stdin.buffer.readline
for _ in range(int(input())):
	n = int(input())
	(*a,) = map(int, input().split())
	d = {}
	for i in a:
		d[i] = d.get(i, 0) + 1
	ans = cnt = 0
	for i in range(n + 1):
		if d.get(i, 0) < 2:
			ans = i
			break
	for i in range(ans, n + 1):
		if i not in d:
			ans += i
			break
	print(ans)


def mex(nList):
	mex = 0
	for i in nList:
		if i <= mex:
			mex += 1
	if mex == max(nList):
		return mex + 1
	else:
		return mex
t = int(input())
while t > 0:
	t = t - 1
	n = int(input())
	lst = []
	lst = input().split()
	ar = []
	cnt = [0] * 101
	for i in range(n):
		ar.append(int(lst[i]))
		cnt[ar[i]] += 1
	x = 0
	y = 0
	for i in range(0, 101):
		if cnt[i] > 0:
			x = i + 1
			cnt[i] -= 1
		else:
			break
	for i in range(0, 101):
		if cnt[i] > 0:
			y = i + 1
			cnt[i] -= 1
		else:
			break
	print(x + y)


from sys import stdin, stdout
from math import gcd, sqrt, inf
from collections import deque
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 1 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
N = inf
for _ in range(I()):
	n = I()
	(*a,) = R()
	x = y = 0
	for i in range(102):
		p = a.count(i)
		if p < 1:
			if not x:
				x = i + 1
			y = i
			break
		if p < 2 and (not x):
			x = i + 1
	print(x + y - 1)


for ii in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	m = max(a)
	x = 0
	for i in range(m + 2):
		if i not in a:
			x += i
			break
		else:
			a.remove(i)
	x1 = 0
	for i in range(m + 2):
		if i not in a:
			x1 += i
			break
	print(x + x1)


t = int(input())
for _ in range(t):
	n = int(input())
	d = {i: 0 for i in range(101)}
	arr = list(map(int, input().split()))
	if arr.count(0) == 0:
		print(0)
	else:
		for v in arr:
			d[v] += 1
		r1 = 0
		r2 = 0
		for i in range(100, -1, -1):
			if d[i] == 0:
				r1 = i
			if d[i] <= 1:
				r2 = i
		print(r1 + r2)


for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	counts = [0] * 102
	for i in arr:
		counts[i] += 1
	ans = 0
	for i in range(102):
		if counts[i] == 0:
			ans += i
			counts[i] += 1
			break
	for i in range(102):
		if counts[i] <= 1:
			ans += i
			break
	print(ans)


import math
from sys import stdin, stdout

def getInt():
	return int(stdin.readline())

def getInts():
	return list(map(int, stdin.readline().split()))

def solve():
	n = getInt()
	a = getInts()
	has = [0 for i in range(101)]
	for i in range(n):
		has[a[i]] += 1
	x1 = 0
	x2 = 0
	for i in range(101):
		if has[i] == 0:
			x1 = i
			break
	if x1 == 0:
		return 0
	if x1 == n:
		return n
	for i in range(101):
		if has[i] == 1 or has[i] == 0:
			x2 = i
			break
	return x1 + x2

def main():
	t = getInt()
	for i in range(t):
		stdout.write(str(solve()) + '\n')
main()


import math
import collections

def solve(n, a):
	ans = 0
	for i in range(0, 101):
		if a.count(i) > 0:
			a.remove(i)
		else:
			ans += i
			break
	for i in range(0, 101):
		if a.count(i) > 0:
			a.remove(i)
		else:
			ans += i
			break
	return ans
t = int(input())
for t in range(t):
	n = int(input())
	a = [int(s) for s in input().split()]
	result = solve(n, a)
	print(result)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	m = 0
	ans = 0
	f = 0
	for i in range(n + 1):
		k = a.count(i)
		if k == 1:
			ans = i + 1
			f = 1
		elif k > 1:
			if f == 0:
				ans = i + 1
				m = i + 1
			else:
				ans = i + 1
		elif k == 0:
			break
	print(ans + m)


import sys, math
input = sys.stdin.readline

def findMex(l):
	d2 = {}
	for i in l:
		d2[i] = 1
	j = 0
	while True:
		try:
			x = d2[j]
			j += 1
		except:
			break
	return j
t = int(input())
for r in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in l:
		try:
			d[i] += 1
		except:
			d[i] = 1
	ll = []
	for i in d:
		ll.append([i, d[i]])
	ll.sort(key=lambda x: x[0])
	set1 = []
	set2 = []
	start = ll[0][0]
	ll[0][1] -= 1
	length = len(ll)
	set1.append(start)
	for i in range(1, length):
		if ll[i][0] == start + 1:
			set1.append(ll[i][0])
			ll[i][1] -= 1
			start = ll[i][0]
		else:
			break
	for i in range(length):
		if ll[i][1] > 0:
			set2.append(ll[i][0])
	ans = findMex(set1) + findMex(set2)
	print(ans)


import sys
import collections
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		N = int(input())
		A = [int(x) for x in input().split()]
		c = collections.Counter(A)
		ans = []
		for i in range(max(A) + 2):
			if len(ans) == 2:
				break
			if c[i] == 0:
				if len(ans) == 0:
					ans.append(i)
					ans.append(i)
				else:
					ans.append(i)
			elif c[i] == 1:
				if len(ans) == 0:
					ans.append(i)
		print(sum(ans))
main()


def solve(s, L):
	count = [0 for i in range(104)]
	for i in s:
		count[i] += 1
	i = 0
	f = 0
	mex = 0
	while i < len(count):
		if count[i] == 1 and f != 1:
			mex += i
			f = 1
		elif count[i] == 0:
			if f == 0:
				return 2 * i
			else:
				return mex + i
		i += 1
for i in range(int(input())):
	L = int(input())
	s = list(map(int, input().split()))
	print(solve(s, L))


import sys
t = int(input().strip())
for a0 in range(t):
	n = int(input())
	l1 = [int(i) for i in input().split()]
	l = []
	r = []
	for i in l1:
		if i in l and i in r:
			continue
		elif i in l:
			r.append(i)
		else:
			l.append(i)
	r.sort()
	l.sort()
	a = 0
	b = 0
	countl = 0
	countr = 0
	if len(l) == 0:
		a = 0
	else:
		for i in range(len(l)):
			if l[i] != i:
				a = i
				break
			else:
				countl += 1
	if countl == len(l):
		a = len(l)
	if len(r) == 0:
		b = 0
	else:
		for i in range(len(r)):
			if r[i] != i:
				b = i
				break
			else:
				countr += 1
	if countr == len(r):
		b = len(r)
	print(a + b)


for _ in range(int(input())):
	n = int(input())
	L = [int(x) for x in input().split()]
	l = sorted(set(L))
	x = []
	y = []
	for i in l:
		if L.count(i) >= 2:
			x.append(i)
			y.append(i)
		else:
			x.append(i)
	x.sort()
	y.sort()
	a = 0
	b = 0
	for i in x:
		if i != a:
			break
		else:
			a += 1
	for j in y:
		if j != b:
			break
		else:
			b += 1
	print(a + b)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	b = 0
	c = 0
	for i in range(n):
		if i in a:
			a.remove(i)
		else:
			b = i
			break
		if len(a) == 0:
			b = i + 1
			break
	for i in range(n):
		if i in a:
			a.remove(i)
		else:
			c = i
			break
		if len(a) == 0:
			c = i + 1
	print(b + c)


def Mex(arr):
	(i, n) = (0, len(arr))
	curr = 0
	while i < n:
		if arr[i] != curr:
			return curr
		else:
			while i < n and arr[i] == curr:
				i += 1
			curr += 1
	return curr

def Subset_Mex(n, arr):
	arr.sort()
	i = 0
	(A, B) = ([], [])
	while i < n:
		if i < n - 1 and arr[i] == arr[i + 1]:
			A.append(arr[i])
			B.append(arr[i])
			i += 2
		else:
			A.append(arr[i])
			i += 1
	return Mex(A) + Mex(B)
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	print(Subset_Mex(n, arr))


t = int(input())
from collections import Counter
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	X = [0] * 102
	for a in A:
		X[a] += 1
	flag = True
	ans = 0
	for i in range(102):
		if X[i] == 0:
			if flag:
				ans += 2 * i
				break
			else:
				ans += i
				break
		elif X[i] == 1:
			if flag:
				ans += i
				flag = False
		else:
			pass
	print(ans)


for p in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	for j in range(101):
		if j not in a:
			m = j
			break
		if j in a:
			a.remove(j)
	for j in range(101):
		if j not in a:
			b = j
			break
	print(m + b)


from collections import Counter
for _ in range(0, int(input())):
	input()
	c = Counter(map(int, input().split()))
	m = 0
	M = 0
	i = 0
	while c[i] > 1:
		m += 1
		M += 1
		i += 1
	while c[i] > 0:
		M += 1
		i += 1
	print(m + M)


from collections import defaultdict as dd, deque, Counter
t = int(input())
for _ in range(t):
	n = int(input())
	A = Counter((int(x) for x in input().split()))
	res = 0
	i = 0
	while True:
		if A[i] >= 2:
			res += 2
		else:
			break
		i += 1
	while True:
		if A[i] >= 1:
			res += 1
		else:
			break
		i += 1
	print(res)


t = int(input())
for i in range(t):
	q = {}
	n = int(input())
	a = list(map(int, input().split()))
	r = 0
	for i in range(2):
		w = 0
		while w in a:
			a.remove(w)
			w += 1
		r += w
	print(r)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	a = [0 for i in range(max(l) + 1)]
	for i in l:
		a[i] += 1
	(m, n) = (0, 0)
	check = 0
	k = max(l)
	for i in range(k + 1):
		if a[i] == 0:
			(m, n) = (i, i)
			check = 1
			break
		elif a[i] == 1:
			m = i
			check = 2
			break
	if check == 1:
		print(m + n)
	elif check == 2:
		for j in range(i + 1, k + 1):
			if a[j] == 0:
				n = j
				check = 0
				break
		if check == 0:
			print(m + n)
		else:
			print(m + k + 1)
	else:
		print(2 * k + 2)


t = int(input())
for index in range(t):
	row = [0] * 101
	n = input()
	l = input().split()
	for c in l:
		row[int(c)] += 1
	k = 0
	while row[k] > 1:
		k += 1
	m = k
	while row[m]:
		m += 1
	print(k + m)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ref = [i for i in range(max(a) + 2)]
	mex1 = 0
	for x in ref:
		if x not in a:
			mex1 = x
			break
	for i in range(mex1):
		if i in a:
			a.remove(i)
	mex2 = 0
	for x in ref:
		if x not in a:
			mex2 = x
			break
	print(mex1 + mex2)


T = int(input())
for _ in range(T):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	if arr[0] == 0:
		my_dict = dict()
		for i in arr:
			if i in my_dict:
				my_dict[i] += 1
			else:
				my_dict[i] = 1
		(a, b) = ([], [])
		for i in my_dict:
			if my_dict[i] == 1:
				a.append(i)
			else:
				a.append(i)
				b.append(i)
		ans = 0
		if len(a) > 0:
			up = a[-1]
			f1 = 0
			for i in range(0, up + 1):
				if a[i] == i:
					continue
				else:
					f1 = 1
					ans += i
					break
			if f1 == 0:
				ans += up + 1
		if len(b) > 0:
			up = b[-1]
			f2 = 0
			for i in range(0, up + 1):
				if b[i] == i:
					continue
				else:
					f2 = 1
					ans += i
					break
			if f2 == 0:
				ans += up + 1
		print(ans)
	else:
		print(0)


t = int(input())
while t > 0:
	n = int(input())
	x = [int(i) for i in input().split()]
	x.sort()
	if 0 not in x:
		print(0)
	else:
		a = []
		b = []
		res = 0
		m = 0
		a.append(x[0])
		for i in range(1, n):
			if a[m] + 1 == x[i]:
				a.append(x[i])
				m += 1
			elif a[m] == x[i]:
				if x[i] not in b:
					b.append(x[i])
			else:
				if x[i] not in b:
					b.append(x[i])
				break
		res = a[m] + 1
		z = 0
		for i in range(len(b)):
			if b[i] == z:
				z += 1
			else:
				break
		res += z
		print(res)
	t -= 1


T = int(input())
from collections import Counter
for _ in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	b = Counter(a)
	(al, be) = (-1, -1)
	for i in range(102):
		if b[i] >= 2:
			continue
		elif b[i] == 1:
			if al == -1:
				al = i
		elif b[i] == 0:
			if al == -1:
				(al, be) = (i, i)
				print(al + be)
				break
			else:
				be = i
				print(al + be)
				break


for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	a = []
	b = []
	ar.sort()
	if ar[0] == 0:
		a.append(ar[0])
	else:
		print(0)
		continue
	for i in ar[1:]:
		if i == a[-1] + 1:
			a.append(i)
		elif len(b) == 0 and i == 0:
			b.append(i)
		elif len(b) > 0 and i == b[-1] + 1:
			b.append(i)
	if len(a) == 0:
		aa = 0
	else:
		aa = a[-1] + 1
	if len(b) == 0:
		bb = 0
	else:
		bb = b[-1] + 1
	print(aa + bb)


t = int(input(''))
arr = []
for i in range(t):
	n = int(input(''))
	arr.append(list(map(int, input().split())))
for i in arr:
	n = len(i)
	cnt = [0] * 101
	sol = 0
	for j in range(n):
		cnt[i[j]] += 1
	for j in range(len(cnt)):
		if cnt[j] < 2:
			sol += j
			break
	for j in range(len(cnt)):
		if cnt[j] < 1:
			sol += j
			break
	print(sol)


mod = 10 ** 9 + 7

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	ans = 0
	cnt = [0 for i in range(1000)]
	for x in a:
		cnt[x] += 1
	for i in range(1001):
		if cnt[i] > 1:
			cnt[i] -= 1
			ans += 1
		else:
			break
	for i in range(1001):
		if cnt[i] > 0:
			ans += 1
		else:
			break
	print(ans)
t = int(input())
while t > 0:
	solve()
	t -= 1


import itertools
import math
import sys
from collections import defaultdict

def stdinWrapper():
	data = '4\n6\n0 2 1 5 0 1\n3\n0 1 2\n4\n0 2 0 1\n6\n1 2 3 4 5 6\n\n'
	for line in data.split('\n'):
		yield line
if '--debug' not in sys.argv:

	def stdinWrapper():
		while True:
			yield input()
inputs = stdinWrapper()

def inputWrapper():
	return next(inputs)

def getType(_type):
	return _type(inputWrapper())

def getArray(_type):
	return [_type(x) for x in inputWrapper().split()]

def solve(a):
	a = sorted(a)
	left = []
	right = []
	for x in a:
		if not left or left[-1] != x:
			left.append(x)
		elif not right or right[-1] != x:
			right.append(x)

	def mex(arr):
		if not arr:
			return 0
		for i in range(max(arr)):
			if i not in arr:
				return i
		return max(arr) + 1
	return mex(left) + mex(right)
t = getType(int)
for _ in range(t):
	n = getType(int)
	a = getArray(int)
	res = solve(a)
	print(res)


def solve():
	n = int(input())
	cntr = [0] * 200
	arr = [int(v) for v in input().split()]
	for v in arr:
		cntr[v] += 1
	ans = 0
	st = 0
	for i in range(len(cntr)):
		if cntr[i] >= 2:
			ans = i + 1
		else:
			st = i
			break
	while st < len(cntr) and cntr[st]:
		st += 1
	ans += st
	print(ans)
t = int(input())
for _ in range(t):
	solve()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	cnt1 = [0] * 110
	cnt2 = [0] * 110
	for i in range(n):
		if cnt1[a[i]] == 0:
			cnt1[a[i]] += 1
		else:
			cnt2[a[i]] += 1
	(ans1, ans2) = (0, 0)
	for i in range(110):
		if cnt1[i] == 0:
			ans1 = i
			break
	for i in range(110):
		if cnt2[i] == 0:
			ans2 = i
			break
	print(ans1 + ans2)


from sys import stdin, stdout
from collections import Counter
from itertools import permutations
import bisect
import math
I = lambda : map(int, stdin.readline().split())
I1 = lambda : stdin.readline()
for _ in range(int(I1())):
	n = int(I1())
	a = list(I())
	m = max(a)
	d = {i: 0 for i in range(101)}
	for x in a:
		d[x] += 1
	ans = 0
	for x in range(101):
		if d[x] == 0:
			ans += x
			break
		d[x] -= 1
	for x in range(101):
		if d[x] == 0:
			ans += x
			break
		d[x] -= 1
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	x = dict()
	for i in a:
		if x.get(i, 0) == 0:
			x[i] = 1
		else:
			x[i] += 1
	b = set(a)
	ans = 0
	for i in range(101):
		if i not in b:
			ans += i
			break
	for i in range(101):
		if x.get(i, 0) < 2:
			ans += i
			print(ans)
			break


from sys import stdin
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	a = sorted(map(int, stdin.readline().split()))
	(mex_a, mex_b) = (0, 0)
	for i in a:
		if i == mex_a:
			mex_a += 1
		elif i == mex_b:
			mex_b += 1
	print(mex_a + mex_b)


from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	c = Counter(a)
	ans = []
	a1 = 0
	for i in range(n + 1):
		if c[i] > 0:
			c[i] -= 1
			a1 += 1
		else:
			break
	a2 = 0
	for i in range(n + 1):
		if c[i] > 0:
			c[i] -= 1
			a2 += 1
		else:
			break
	print(a1 + a2)


import sys
input = sys.stdin.buffer.readline

def solution():
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in range(n):
		d[l[i]] = d.get(l[i], 0) + 1
	flag = 0
	for i in range(101):
		if d.get(i, 0) == 0:
			m2 = i
			flag = 1
			m1 = i
			break
		if d.get(i, 0) == 1:
			m1 = i
			break
	if flag == 0:
		for i in range(101):
			if d.get(i, 0) == 0:
				m2 = i
				break
	print(m1 + m2)
t = int(input())
for _ in range(t):
	solution()


t = int(input())
for _ in range(t):
	__ = input()
	arr = list(map(int, input().split()))
	arr.sort()
	s = -1
	e = -1
	for i in arr:
		if i == s + 1:
			s = i
		elif i == e + 1:
			e = i
	print(max(0, s + 1) + max(0, e + 1))


getn = lambda : int(input())
getlist = lambda : list(map(int, input().split(' ')))

def solve():
	n = getn()
	arr = getlist()
	arr.sort()
	left = [arr[0]]
	l = 1 if arr[0] == 0 else 0
	right = []
	r = 0
	for i in range(1, len(arr)):
		num = arr[i]
		if l == num:
			l += 1
			left.append(num)
		elif left[-1] < l < num:
			l = left[-1] + 1
			left.append(num)
		else:
			last_r = right[-1] if len(right) else 0
			if r == num:
				r += 1
				right.append(num)
			elif last_r < r <= num:
				r = last_r + 1
				right.append(num)
			else:
				right.append(num)
	print(l + r)
	return
t = getn()
while t > 0:
	solve()
	t -= 1


def solve(n, arr):
	set1 = []
	set2 = []
	arr.sort()
	current_inserted = -1
	for i in range(n):
		if arr[i] == current_inserted:
			set2.append(arr[i])
		else:
			set1.append(arr[i])
			current_inserted = arr[i]
	set1.sort()
	set2.sort()
	total = 0
	current = 0
	for i in range(len(set1)):
		if set1[i] == current:
			current += 1
	total += current
	current = 0
	for i in range(len(set2)):
		if set2[i] == current:
			current += 1
	total += current
	return total
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	print(solve(n, arr))


t = int(input())
for _ in range(t):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	b = []
	c = []
	prev = float('inf')
	for i in range(n):
		if a[i] == prev:
			c.append(a[i])
		else:
			b.append(a[i])
			prev = a[i]
	x = 0
	for i in range(len(b)):
		if b[i] > x:
			break
		elif b[i] == x:
			x += 1
	y = 0
	for i in range(len(c)):
		if c[i] > y:
			break
		elif c[i] == y:
			y += 1
	print(x + y)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	cnt = [0] * 205
	for x in a:
		cnt[x] += 1
	for i in range(205):
		if cnt[i] == 0:
			break
	ans = i
	for i in range(205):
		if cnt[i] < 2:
			break
	ans += i
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	mex_a = 0
	mex_b = 0
	for i in a:
		if mex_a == i:
			mex_a += 1
		elif mex_b == i:
			mex_b += 1
	print(mex_b + mex_a)


t = int(input())
while t > 0:
	n = int(input())
	a = [int(x) for x in input().split()]
	f = [0] * 101
	ans = 0
	for i in range(n):
		f[a[i]] += 1
	for i in range(len(f)):
		if f[i] != 0:
			f[i] -= 1
		else:
			ans += i
			break
	for i in range(len(f)):
		if f[i] != 0:
			f[i] -= 1
		else:
			ans += i
			break
	print(ans)
	t -= 1


import math
tst = int(input())
t = 1
while t <= tst:
	n = int(input())
	ls = list(map(int, input().split()))
	ls1 = [0] * 105
	sum = i = 0
	while i < n:
		ls1[ls[i]] += 1
		i += 1
	i = 0
	while i <= 105:
		if ls1[i] > 0:
			ls1[i] -= 1
		else:
			sum += i
			break
		i += 1
	i = 0
	while i <= 105:
		if ls1[i] > 0:
			ls1[i] -= 1
		else:
			sum += i
			break
		i += 1
	print(sum)
	t += 1


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	for i in a:
		if d.get(i) == None:
			d[i] = 1
		else:
			d[i] += 1
	if d.get(0) == None:
		print(0)
		continue
	mex = -1
	mex1 = -1
	flag = 0
	for i in range(0, n + 1):
		if d.get(i) == None:
			mex = i
			break
		elif d[i] > 1:
			continue
		elif flag == 0:
			flag = 1
			mex1 = i
	if flag == 1:
		print(mex1 + mex)
	else:
		print(2 * mex)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s = sorted(set(a))
	(A, B) = (0, 0)
	b = False
	for i in range(len(s)):
		if s[i] == i:
			A += 1
			if a.count(i) > 1 and (not b):
				B += 1
			else:
				b = True
		else:
			break
	print(A + B)


test = int(input())
for _ in range(test):
	n = int(input())
	arr = list(map(int, input().split(' ')))
	dc = {}
	for num in arr:
		dc[num] = dc.get(num, 0) + 1
	m = max(arr)
	count = 0
	ans = 0
	flag = True
	for i in range(m + 2):
		if i in dc:
			if dc[i] < 2 and flag:
				flag = False
				count += 1
				ans += i
		elif count:
			count += 1
			ans += i
		else:
			count += 2
			ans += 2 * i
		if count == 2:
			break
	print(ans)


from collections import Counter

def mexit(n, a):
	b = list(set(a))
	ca = Counter(a)
	b.sort()
	i = 0
	(m1, m2) = (-1, -1)
	while i < len(b):
		if b[i] != i:
			m1 = i
			break
		ca[i] -= 1
		i += 1
	if m1 < 0:
		m1 = i
	left = sorted([i for i in ca if ca[i] != 0])
	if not left:
		return m1
	i = 0
	while i < len(left):
		if left[i] != i:
			m2 = i
			break
		i += 1
	if m2 < 0:
		m2 = i
	return m1 + m2
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	print(mexit(n, a))


import sys
from collections import Counter

def main():
	tn = int(input())
	for ti in range(tn):
		n = int(input())
		A = Counter((int(a) for a in input().split()))
		for i in range(200):
			if A[i] == 0:
				a = i
				break
			A[i] -= 1
		for i in range(200):
			if A[i] == 0:
				b = i
				break
			A[i] -= 1
		print(a + b)
main()


n = int(input())
for i in range(n):
	input()
	nums = list(map(int, input().split()))
	tem = [0 for j in range(len(nums))]
	for j in range(len(nums)):
		if nums[j] < len(tem):
			tem[nums[j]] += 1
	first = tem.index(0) if 0 in tem else len(tem)
	for j in range(len(tem[:first])):
		tem[j] -= 1
	second = tem.index(0)
	print(first + second)


from collections import Counter
for i in range(int(input())):
	n = int(input())
	r = list(map(int, input().split()))
	dic = Counter(r)
	chk = 0
	r = 0
	re = 0
	while dic[chk] > 1:
		chk += 1
	if dic[chk]:
		re += chk
		chk += 1
		while dic[chk]:
			chk += 1
		re += chk
	else:
		re = 2 * chk
	print(re)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	A = {a[0]}
	B = set()
	for i in range(1, len(a)):
		if a[i] == a[i - 1]:
			B.add(a[i])
		else:
			A.add(a[i])
	(x, y) = (0, 0)
	while x in A:
		x += 1
	while B and y in B:
		y += 1
	print(x + y)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192
from sys import stderr

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def pow(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def gcd(a, b):
	if a == b:
		return a
	while b > 0:
		(a, b) = (b, a % b)
	return a

def solve():
	n = int(inp())
	ar = lis()
	c = counter(ar)
	l1 = []
	l2 = []
	f = -1
	for i in range(max(ar) + 2):
		if c[i] == 0:
			if f == -1:
				print(2 * i)
				break
			else:
				print(f + i)
				break
		elif c[i] == 1:
			if f == -1:
				f = i
testcase(int(inp()))


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	C = list(map(int, input().split(' ')))
	m = max(C)
	A = []
	for i in range(m + 1):
		if i in C:
			A.append(i)
			C.remove(i)
	A.sort()
	C.sort()
	ans = 0
	for i in range(max(A) + 1):
		if i not in A:
			ans += i
			break
	else:
		ans += max(A) + 1
	if len(C) != 0:
		for i in range(max(C) + 1):
			if i not in C:
				ans += i
				break
		else:
			ans += max(C) + 1
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().strip().split()))[:n]
	my_hash = [0] * 200
	for i in arr:
		my_hash[i] += 1
	a_mex = None
	b_mex = None
	for i in range(len(my_hash)):
		if my_hash[i] == 0:
			if a_mex is None:
				a_mex = i
			if b_mex is None:
				b_mex = i
			break
		elif my_hash[i] == 1:
			if a_mex is None:
				a_mex = i
	print(a_mex + b_mex)


import sys
from collections import defaultdict
input = sys.stdin.readline
from collections import deque

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
nb = inp()
for i in range(nb):
	temp = 2
	n = inp()
	tab = inlt()
	res = 0
	chiffre = 0
	while temp != 0:
		ite = 0
		for i in range(n):
			if tab[i] == chiffre and ite < temp:
				res += 1
				ite += 1
		if ite != temp:
			temp = ite
		chiffre += 1
	print(res)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	ans = 0
	c = 0
	for i in range(max(l) + 1):
		if i not in l:
			if c == 0:
				ans = 2 * i
				c = 'hi'
			else:
				ans += i
				c = 'hi'
			break
		elif l.count(i) == 1 and c == 0:
			ans += i
			c = 1
	if c == 1:
		ans += i + 1
	elif c == 0:
		ans = 2 * (i + 1)
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	mp = [0] * 101
	for i in range(n):
		mp[a[i]] += 1
	ans = 0
	k = 2
	for i in range(101):
		if k <= 0:
			break
		if mp[i] == 1 and k == 2:
			ans += i
			k -= 1
		elif k == 1 and mp[i] == 0:
			ans += i
			k -= 1
		elif mp[i] == 0 and k == 2:
			ans += i * 2
			k -= 2
	print(ans)


for _ in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	d = {}
	m = 0
	ans = 0
	for i in l:
		d[i] = 1 if i not in d else d[i] + 1
		m = max(m, i)
	for i in range(m + 2):
		if i in d and d[i] > 0:
			d[i] -= 1
		else:
			ans += i
			break
	for i in range(m + 2):
		if i in d and d[i] > 0:
			d[i] -= 1
		else:
			ans += i
			break
	print(ans)


import sys
input = sys.stdin.readline
from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	mx = max(a)
	freq = defaultdict(int)
	for i in a:
		freq[i] += 1
	if freq[0] == 0:
		print(0)
	else:
		ans = 0
		(mexa, mexb) = (0, 0)
		for i in range(max(a) + 2):
			if freq[i] == 0:
				if mexb:
					ans += i
				else:
					ans = 2 * i
				break
			elif freq[i] == 1 and mexb == 0:
				mexb = 1
				ans += i
			if mexa == 1 and mexb == 1:
				break
		print(ans)


t = int(input())

def mex(arr):
	numbers = [0] * (len(arr) + 1)
	for number in arr:
		if number < len(numbers):
			numbers[int(number)] += 1
	for i in range(len(numbers)):
		if numbers[i] == 0:
			return i
	return len(arr)
for i in range(t):
	n = int(input())
	numbers = list(map(int, input().split()))
	first = []
	second = []
	for number in numbers:
		if numbers.count(number) >= 2:
			first.append(number)
			second.append(number)
		else:
			first.append(number)
	print(mex(first) + mex(second))


import sys, math, heapq, copy
from collections import defaultdict, deque
from bisect import bisect_left, bisect_right
from functools import cmp_to_key
from itertools import groupby
for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in range(0, 101):
		d[i] = 0
	for i in l:
		d[i] += 1
	l1 = []
	flag = -1
	for i in range(0, 101):
		if d[i] == 0:
			l1.append(i)
			l1.append(i)
		if flag == -1 and d[i] == 1:
			l1.append(i)
			flag = 1
		if len(l1) >= 2:
			break
	print(l1[0] + l1[1])


for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in l:
		if i not in d:
			d[i] = 1
		else:
			d[i] += 1
	k = []
	k1 = []
	for i in d:
		if d[i] >= 2:
			k += [i]
			k1 += [i]
		else:
			k += [i]
	for j in range(len(k) + 1):
		if j not in k:
			break
	for h in range(len(k1) + 1):
		if h not in k1:
			break
	print(j + h)


t = int(input())
for z in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	a = []
	b = []
	sum = 0
	for i in l:
		if i not in a:
			a.append(i)
		else:
			b.append(i)
	for i in range(101):
		if i not in a:
			sum += i
			break
	for i in range(101):
		if i not in b:
			sum += i
			break
	print(sum)


t = int(input())
for i in range(t):
	a = []
	b = []
	n = int(input())
	a = [int(a) for a in input().split()]
	for j in range(max(a) + 2):
		if a.count(j) < 2:
			b.append(j)
			break
	k = b[0]
	if a.count(b[0]) == 1:
		while a.count(k) != 0 and k < max(a) + 1:
			k = k + 1
		print(b[0] + k)
	elif a.count(b[0]) == 0:
		print(b[0] * 2)


from collections import Counter
T = int(input())
for _ in range(T):
	n = input()
	aa = map(int, input().split())
	cc = Counter(aa)
	ans = 0
	x = -1
	y = -1
	for a in range(101):
		cnt = cc[a]
		if cnt == 0:
			x = a
			if y == -1:
				y = a
			break
		if cnt == 1:
			if y == -1:
				y = a
	print(max(0, x) + max(0, y))


def subset_mex(arr):
	c = arr
	A = []
	B = []
	for x in arr:
		r = 0
		for y in c:
			if x == y:
				r += 1
		if r >= 2:
			A.append(x)
			B.append(x)
		else:
			A.append(x)
	(mex_A, mex_B) = mex(A, B)
	result = mex_A + mex_B
	return result

def mex(A, B):
	a = max(A)
	if len(B) == 0:
		b = -1
	else:
		b = max(B)
	(mex_A, mex_B) = (0, 0)
	for i in range(a + 1, -1, -1):
		if i not in A:
			mex_A = i
	for i in range(b + 1, -1, -1):
		if i not in B:
			mex_B = i
	return (mex_A, mex_B)
t = int(input())
for i in range(t):
	n = int(input())
	x = list(map(int, input().split()))
	c = subset_mex(x)
	print(c)


from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	(a, b, c) = (0, 0, 0)
	(p, q, k) = (1, 1, 1)
	if arr[0] != 0:
		print(0)
		continue
	d = defaultdict(int)
	for i in arr:
		d[i] += 1
	l = list(set(arr))
	l.sort()
	(i, j) = (0, 0)
	while a != len(l):
		if i != l[a]:
			break
		i += 1
		a += 1
	p = i
	for i in range(100):
		if d[i] <= 1:
			j = i
			break
	print(p + j)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(flag, flag1) = (True, True)
	(mex, mex1) = (0, 0)
	count = [0] * (max(a) + 2)
	if 0 not in a:
		print('0')
		continue
	for i in a:
		count[i] += 1
	for i in range(max(a) + 2):
		if count[i] == 0 and flag:
			mex = i
			if flag1:
				mex1 = i
				flag1 = False
			flag = False
		elif count[i] == 1 and flag1:
			mex1 = i
			flag1 = False
	print(mex + mex1)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	a = []
	b = []
	f1 = -1
	l.sort()
	f2 = -1
	for i in l:
		if len(a) == 0:
			a.append(i)
		elif i in a:
			if i not in b:
				b.append(i)
		elif i not in a:
			a.append(i)
	a.sort()
	b.sort()
	for i in range(len(a)):
		if a[i] != i:
			f1 = i
			break
	for i in range(len(b)):
		if b[i] != i:
			f2 = i
			break
	if f1 == -1:
		f1 = len(a)
	if f2 == -1:
		f2 = len(b)
	print(abs(f2 + f1))


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	counter = [0 for _ in range(102)]
	for i in a:
		counter[i] += 1
	mex_a = mex_b = 0
	flag1 = flag2 = True
	for i in range(len(counter)):
		if counter[i] == 0:
			mex_a = i if flag1 else mex_a
			mex_b = i
			break
		elif counter[i] == 1:
			if not flag1:
				mex_b = i
				break
			else:
				flag1 = False
				mex_a = i
	res1 = mex_a + mex_b
	mex_a = mex_b = 0
	flag1 = flag2 = True
	for i in range(len(counter)):
		if counter[i] == 0:
			mex_a = i if flag1 else mex_a
			mex_b = i
			break
		elif counter[i] == 1:
			if flag1:
				flag1 = False
				mex_a = i
	res2 = mex_a + mex_b
	print(max(res1, res2))


t = int(input())
L = []
for i in range(t):
	n = input()
	L.append([])
	L[i] = [int(x) for x in input().split()]

def mex(L):
	i = 0
	while True:
		if i not in L:
			break
		i += 1
	return i

def maxmex(S):
	A = []
	B = []
	S.sort()
	minS = S.pop(0)
	A.append(minS)
	i = 0
	while True:
		if A[i] + 1 in S:
			A.append(S.pop(S.index(A[i] + 1)))
			i += 1
		else:
			break
	B = S
	print(mex(A) + mex(B))
for S in L:
	maxmex(S)


from collections import Counter

def mex(A):
	sA = set(A)
	for i in range(0, 200):
		if i not in sA:
			return i

def ans(A):
	cA = Counter(A)
	A = []
	B = []
	for i in range(0, 200):
		if cA[i] >= 2:
			A += [i]
			B += [i]
		elif cA[i] == 1:
			B += [i]
	return mex(A) + mex(B)
T = int(input())
for t in range(T):
	input()
	A = list(map(int, input().split()))
	print(ans(A))


for _ in range(int(input())):
	n = int(input())
	freq = [0] * 101
	for e in map(int, input().split()):
		freq[e] += 1
	res = 0
	one = False
	for i in range(101):
		if freq[i] == 0:
			break
		if one:
			res += 1
		elif freq[i] > 1:
			res += 2
		else:
			one = True
			res += 1
	print(res)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr = sorted(arr)
	c = Counter(arr)
	ls = []
	a = []
	for i in c:
		if c[i] == 1:
			ls.append(i)
		else:
			ls.append(i)
			a.append(i)
	ans = 0
	f = 0
	f1 = 0
	for i in range(101):
		if f == 0 and i not in ls:
			ans += i
			f = 1
		if f1 == 0 and i not in a:
			ans += i
			f1 = 1
		if f == 1 and f1 == 1:
			break
	print(ans)


from collections import defaultdict
t = int(input())
while t > 0:
	t -= 1
	freq = defaultdict(int)
	n = int(input())
	arr = list(map(int, input().split()))
	for i in arr:
		freq[i] += 1
	set1 = []
	set2 = []
	firstEnd = False
	firstNum = 0
	secondNum = 0
	if freq[0] == 0:
		print(0)
		continue
	if freq[0] == 1:
		firstEnd = True
		firstNum = 0
	for i in range(1, 101):
		if freq[i] >= 2:
			continue
		elif freq[i] == 1 and (not firstEnd):
			firstEnd = True
			firstNum = i
		elif freq[i] == 0:
			secondNum = i
			if not firstEnd:
				firstNum = i
			break
	print(firstNum + secondNum)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split(' ')))
	i = 0
	mex1 = 0
	mex2 = 0
	while l.count(i) > 0:
		if l.count(i) > 1 and mex1 == mex2:
			mex2 = i + 1
		mex1 = i + 1
		i += 1
	print(mex1 + mex2)


for t in range(int(input())):
	n = int(input())
	nums = list(map(int, input().split()))
	re = [0] * 105
	for nu in nums:
		re[nu] += 1
	res = 0
	for i in range(105):
		if re[i] < 1:
			res += i
			break
	for i in range(105):
		if re[i] < 2:
			res += i
			break
	print(res)


from collections import Counter
t = int(input())
for _ in range(1, t + 1):
	l = int(input())
	ar = list(map(int, input().split()))
	res = dict(Counter(ar))
	flag = False
	mex = 0
	for i in range(2147483647):
		if i not in res.keys():
			if flag:
				mex += i
			else:
				mex += 2 * i
			break
		elif res[i] >= 2:
			continue
		elif res[i] == 1:
			if not flag:
				mex += i
				flag = True
			else:
				continue
	print(mex)


from math import gcd
import collections

def counter1(n):
	return sorted(collections.Counter(n).items(), key=lambda x: x[0])

def counter2(n):
	return sorted(collections.Counter(n).items(), key=lambda x: x[1])
mod = 10 ** 9 + 7
n = int(input())
for i in range(n):
	k = int(input())
	ll = list(map(int, input().split()))
	ll.sort()
	(A, B) = ([], [])
	num = 0
	if 0 not in ll:
		print(0)
	elif ll == [i for i in range(0, len(ll))]:
		print(len(ll))
	else:
		result = 0
		mm = collections.Counter(ll)
		num = 0
		while num in mm:
			num += 1
		result += num
		num = 0
		while mm[num] >= 2:
			num += 1
		result += num
		print(result)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = set()
	z = set()
	a.sort()
	for i in range(n):
		if a[i] in s:
			z.add(a[i])
		else:
			s.add(a[i])
	mex = 0
	for (ind, i) in enumerate(s):
		if ind == 0 and i != 0:
			mex += 0
			break
		if i + 1 not in s:
			mex += i + 1
			break
	for (jind, j) in enumerate(z):
		if jind == 0 and j != 0:
			mex += 0
			break
		if j + 1 not in z:
			mex += j + 1
			break
	print(mex)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	lis1 = [arr[0]]
	lis2 = []
	for i in range(n - 1):
		if arr[i + 1] == arr[i]:
			lis2.append(arr[i + 1])
		else:
			lis1.append(arr[i + 1])
	a = 0
	b = 0
	x = len(lis1)
	y = len(lis2)
	for i in range(x):
		if a == lis1[i]:
			a += 1
	for i in range(y):
		if b == lis2[i]:
			b += 1
	print(a + b)


import sys
from collections import defaultdict
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	lis.sort()
	x = -1
	for i in range(n):
		if lis[i] == x + 1:
			x += 1
			lis[i] = -1
	y = -1
	for i in range(n):
		if lis[i] == y + 1:
			y += 1
	print(x + y + 2)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	a = 0
	t = False
	p = 0
	for i in range(0, 101):
		if l.count(i) == 0:
			if not t:
				a += 2 * i
				break
			else:
				a += i
				break
		elif l.count(i) == 1 and (not t):
			a += i
			t = True
	print(a)


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	a = sorted(a)
	ans = 0
	if a.count(0) < 2 and n % 2 == 1:
		for i in range(101):
			if i not in a:
				ans = i
				break
	elif a.count(0) >= 2:
		a1 = [0]
		a2 = []
		for i in range(1, n):
			if a[i] not in a1 and a[i] - 1 in a1:
				a1.append(a[i])
			else:
				a2.append(a[i])
		for i in range(101):
			if i not in a1:
				ans += i
				break
		for i in range(101):
			if i not in a2:
				ans += i
				break
		for i in range(101):
			if i not in a:
				ans = max(ans, i)
				break
	else:
		for i in range(101):
			if i not in a:
				ans += i
				break
	print(ans)


q = int(input())
for _ in range(q):
	n = int(input())
	l = list(map(int, input().split()))
	wyn = 0
	stop = False
	for i in range(101):
		if not stop:
			if l.count(i) >= 2:
				wyn += 2
			if l.count(i) == 1:
				wyn += 1
				stop = True
			if l.count(i) == 0:
				stop = True
				break
		elif l.count(i) >= 1:
			wyn += 1
		else:
			break
	print(wyn)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	cnt = [0 for i in range(101)]
	for x in a:
		cnt[x] += 1
	ans = -1
	for i in range(102):
		if cnt[i] == 1 and ans == -1:
			ans = i
		if not cnt[i]:
			ans = ans + i if ans != -1 else 2 * i
			break
	print(ans)


import sys
import math
from collections import Counter, defaultdict
LI = lambda : list(map(int, input().split()))
MAP = lambda : map(int, input().split())
IN = lambda : int(input())
S = lambda : input()

def case():
	n = IN()
	a = LI()
	d = Counter(a)
	ans = 0
	b = set(a)
	for i in range(101):
		if i not in b:
			ans += i
			break
	for i in range(101):
		if d[i] < 2:
			ans += i
			break
	print(ans)
for _ in range(IN()):
	case()


cases = int(input())
for _ in range(cases):
	n = int(input())
	ds = list(map(int, input().split()))
	index = 102
	cn = [0] * index
	for v in ds:
		cn[v] += 1
	(a, b) = (0, 0)
	for i in range(index):
		if cn[i] == 0:
			b = i
			break
		else:
			cn[i] -= 1
	for i in range(index):
		if cn[i] == 0:
			a = i
			break
	print(a + b)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ar = []
	for i in a:
		if a.count(i) > 1:
			ar.append(i)
	ai = dict.fromkeys(ar)
	l = dict.fromkeys(a)
	ai = sorted(ai)
	l = sorted(l)
	c = 0
	b = 0
	if 0 in ai:
		for i in range(len(ai)):
			if i == ai[i]:
				c += 1
			else:
				break
	elif len(ai) == 0:
		c = 0
	else:
		c = 0
	if 0 in l:
		for i in range(len(l)):
			if i == l[i]:
				b += 1
			else:
				break
	elif len(l) == 0:
		b = 0
	else:
		b = 0
	print(c + b)


for t in range(int(input())):
	n = int(input())
	b = list(map(int, input().split()))
	a = [0 for i in range(101)]
	for i in range(n):
		a[b[i]] += 1
	store = 0
	flag = 2
	for i in range(101):
		if a[i] == 1 and flag == 2:
			store = i
			flag = 0
		if a[i] == 0:
			if flag == 0:
				flag = 1
				break
			break
	if flag == 1:
		print(store + i)
	else:
		print(2 * i)


T = int(input())
for i in range(0, T):
	n = int(input())
	array = [int(s) for s in input().split()]
	array.sort()
	A = []
	B = []
	for i in range(0, len(array)):
		if i == 0:
			A.append(array[i])
		elif array[i] == array[i - 1]:
			B.append(array[i])
		else:
			A.append(array[i])
	A.sort()
	B.sort()
	value1 = 0
	value2 = 0
	num = 0
	if len(A) == 0:
		value1 = 0
	else:
		for i in range(0, len(A)):
			if A[i] == num:
				num += 1
		value1 = num
	num = 0
	if len(B) == 0:
		value2 = 0
	else:
		for i in range(0, len(B)):
			if B[i] == num:
				num += 1
		value2 = num
	ans = value1 + value2
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	num = [0 for _ in range(101)]
	for j in a:
		num[j] += 1
	flg_1 = 0
	flg_0 = 0
	ans = 0
	for k in range(n + 1):
		if flg_0 != 0:
			break
		elif flg_1 == 0 and num[k] == 1:
			ans += k
			flg_1 = 1
		elif flg_0 == 0 and num[k] == 0:
			if flg_1 == 1:
				ans += k
				flg_0 = 1
			else:
				ans += 2 * k
				flg_0 = 1
	print(ans)


import math
t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	if a.count(0) == 0:
		print('0')
	elif a.count(0) == 1:
		a.sort()
		count = 0
		ans = 0
		for i in range(n - 1):
			if a[i + 1] - a[i] == 0 or a[i + 1] - a[i] == 1:
				count += 1
				pass
			else:
				ans = a[i]
				break
		if count == n - 1:
			print(a[-1] + 1)
		else:
			print(ans + 1)
	else:
		a.sort()
		j = 0
		b = []
		while j < n:
			if j in a:
				b.append(j)
				a.remove(j)
				j += 1
			else:
				break
		a.sort()
		ans = b[-1] + 1
		count = 0
		ans1 = 0
		for i in range(len(a) - 1):
			if a[i + 1] - a[i] == 0 or a[i + 1] - a[i] == 1:
				count += 1
				pass
			else:
				ans1 = a[i] + 1
				break
		if count == len(a) - 1:
			print(a[-1] + 1 + ans)
		else:
			print(ans1 + ans)


T = lambda : range(int(input()))
A = lambda : list(map(int, input().split()))
for _ in T():
	n = int(input())
	a = A()
	a.sort()
	p = [0] * 101
	for i in a:
		p[i] += 1
	i = 0
	acn = 0
	bcn = 0
	st = True
	while True:
		if not p[i]:
			acn = i
			if st:
				bcn = i
			break
		elif p[i] > 1:
			acn += 1
			if st:
				bcn += 1
		elif p[i] > 0:
			acn += 1
			st = False
		i += 1
	print(acn + bcn)


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	s1 = -1
	s2 = -1
	for i in a:
		if i - 1 == s1:
			s1 += 1
		elif i - 1 == s2:
			s2 += 1
		elif i == s1 or i == s2:
			continue
		else:
			break
	print(s2 + 1 + s1 + 1)


for i in range(int(input())):
	n = int(input())
	u = list(map(int, input().split()))
	u.sort()
	a = []
	k = 1
	for i in range(1, n):
		if u[i] == u[i - 1]:
			k += 1
		else:
			a.append((k, u[i - 1]))
			k = 1
	a.append((k, u[-1]))
	cur1 = -1
	for i in range(len(a)):
		if a[i][1] == cur1 + 1 and a[i][0] > 1:
			cur1 += 1
		else:
			break
	cur2 = -1
	for i in range(len(a)):
		if a[i][1] == cur2 + 1:
			cur2 += 1
		else:
			break
	print(cur1 + cur2 + 2)


for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	temp = set(lst)
	ans = 0
	for i in range(101):
		if i not in lst:
			ans += i
			break
	done = False
	for j in range(i):
		if lst.count(j) < 2:
			ans += j
			done = True
			break
	if not done:
		ans += i
	print(ans)


import math

def main():
	t = int(input())
	for _ in range(t):
		print(case())

def case():
	n = int(input())
	a = list(map(int, input().split()))
	ans = 0
	for _ in range(2):
		if len(a) == 0:
			break
		for num in range(max(a) + 2):
			if num in a:
				a.remove(num)
			else:
				ans += num
				break
	return ans
main()


from itertools import permutations
from collections import defaultdict
from math import *
import os
import sys
from io import BytesIO, IOBase
from heapq import nlargest
from bisect import *
import copy
import itertools
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
t = int(input())
while t:
	t -= 1
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	(m1, m2) = (0, 0)
	(c1, c2) = (0, 0)
	for i in range(n):
		isTaken = False
		if arr[i] == c1:
			c1 += 1
			m1 += 1
			isTaken = True
		if arr[i] == c2 and isTaken == False:
			c2 += 1
			m2 += 1
	print(m1 + m2)


t = int(input())
from collections import Counter
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	c = Counter(a)
	lo = 0
	hi = 0
	for i in range(102):
		if c[i] < 2:
			break
		else:
			lo = i + 1
	for i in range(102):
		if c[i] == 0:
			break
		else:
			hi = i + 1
	print(lo + hi)


t = int(input())
for i in range(t):
	freq = [0 for i in range(101)]
	n = int(input())
	a = list(map(int, input().split()))
	for num in a:
		freq[num] += 1
	mexa = -1
	for (i, count) in enumerate(freq):
		if count == 1 and mexa == -1:
			mexa = i
		elif count == 0:
			if mexa == -1:
				mexa = i
				mexb = i
			else:
				mexb = i
			break
	print(mexa + mexb)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	dic = [0] * 101
	for i in range(n):
		dic[a[i]] += 1
	ans = 0
	for i in range(101):
		if dic[i] < 2:
			ans += i
			break
	for i in range(101):
		if dic[i] < 1:
			ans += i
			break
	print(ans)


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	(a, b) = (set(), set())
	for i in s:
		if i in a:
			b.add(i)
		else:
			a.add(i)
	mexa = 0
	for i in range(n + 1):
		if i not in a:
			mexa = i
			break
	mexb = 0
	for i in range(n + 1):
		if i not in b:
			mexb = i
			break
	print(mexa + mexb)


t = int(input())
while t != 0:
	t -= 1
	n = int(input())
	li = list(map(int, input().split()))
	dic = {}
	dic2 = {}
	a = 0
	b = 0
	flag = 0
	ans = [0] * 101
	for i in li:
		if i not in dic and i not in dic2:
			dic[i] = 1
		else:
			ans[i] = 1
			dic2[i] = 1
			if i in dic:
				dic.pop(i)
	le = len(dic2)
	c = 0
	for i in range(0, 101):
		if ans[i] == 0 and le != 0:
			if c < le:
				a = i
				flag = 1
				break
			else:
				break
		else:
			c += 1
	if flag == 0:
		a = le
	for i in dic:
		ans[i] = 1
	for j in range(0, 101):
		if ans[j] == 0:
			b = j
			break
	print(a + b)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import log2, ceil
from heapq import heappush, heappop, heapify
from copy import deepcopy
from collections import deque, Counter as CC
from bisect import bisect_left as bl

def main():
	for t in range(int(input())):
		n = int(input())
		l = [int(j) for j in input().split()]
		m1 = -1
		m2 = -1
		x = CC(l)
		ct = 0
		for i in range(101):
			if m1 != -1 and m2 != -1:
				break
			if x[ct] == 0:
				if m1 == -1:
					m1 = ct
				if m2 == -1:
					m2 = ct
				break
			elif x[ct] == 1:
				if m1 != -1 or m2 != -1:
					pass
				elif m1 == -1:
					m1 = ct
				elif m2 == -1:
					m2 = ct
			ct += 1
		print(m1 + m2)
main()


t = int(input())
for _ in range(t):
	n = int(input())
	li = list(map(int, input().split()))
	li.sort()
	(a, b) = (0, 0)
	c = 0
	for e in li:
		if a == e:
			a += 1
			continue
		if b == e:
			b += 1
	print(a + b)


count = int(input())
for _ in range(count):
	su = 0
	n = int(input())
	a = str(input())
	b = a.split()
	c = [int(i) for i in b]
	c.sort()
	d = set(c)
	e = list(d)
	for i in e:
		c.remove(i)
	mae = max(e)
	if c:
		mac = max(c)
		for i in range(mac + 2):
			if i not in c:
				su += i
				break
	for i in range(mae + 2):
		if i not in e:
			su += i
			break
	print(su)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	i = 0
	ans = 0
	x1 = 0
	x2 = 0
	l1 = []
	l2 = []
	while i < n:
		if a.count(a[i]) >= 2:
			l1.append(a[i])
			l2.append(a[i])
			i += a.count(a[i])
		elif a.count(a[i]) == 1:
			l1.append(a[i])
			i += 1
		else:
			i += 1
	for j in l1:
		if j != x1:
			break
		x1 += 1
	for j in l2:
		if j != x2:
			break
		x2 += 1
	print(x1 + x2)


def read(datatype=int):
	return datatype(input())

def readl(datatype=int):
	return list(map(datatype, input().split()))

def printl(data):
	string = ''
	for d in data:
		string += str(d) + ' '
	print(string)

def mex(arr):
	freq = [False for _ in range(101)]
	for a in arr:
		freq[a] = True
	for i in range(101):
		if not freq[i]:
			return i
	return 101

def testcase():
	n = read()
	arr = readl()
	freq = [0 for _ in range(101)]
	for a in arr:
		freq[a] += 1
	a = []
	b = []
	for i in range(101):
		while freq[i] > 1:
			a.append(i)
			b.append(i)
			freq[i] -= 2
		if freq[i] == 1:
			a.append(i)
	print(mex(a) + mex(b))
	return
t = read()
for _ in range(t):
	testcase()


import math

def calculateMex(Set):
	Mex = 0
	while Mex in Set:
		Mex += 1
	return Mex
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	Set = set()
	Set2 = set()
	for num in a:
		if num in Set:
			Set2.add(num)
		Set.add(num)
	A = calculateMex(Set)
	B = calculateMex(Set2)
	print(A + B)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	if a.count(0) == 0:
		print(0)
	elif a.count(0) == 1:
		for i in range(len(a) + 2):
			if i not in a:
				print(i)
				break
	else:
		for i in range(1, len(a) + 2):
			if a.count(i) < 2:
				if a.count(i) == 1:
					b = i
					while b + 1 in a:
						b += 1
					print(b + i + 1)
					break
				elif a.count(i) == 0:
					print(int(2 * i))
					break
				elif 1 > 0:
					print(i + i + 1)
					break


from collections import Counter
for t in range(int(input())):
	n = int(input())
	frq = Counter(list(map(int, input().split())))
	(ans1, ans2) = (None, None)
	i = 0
	while True:
		if i not in frq:
			ans1 = i
			ans2 = i
			break
		elif frq[i] == 1:
			ans2 = i
			break
		else:
			i += 1
	while ans1 is None:
		if i not in frq:
			ans1 = i
			break
		else:
			i += 1
	print(ans1 + ans2)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def findmex(arr):
	cur = 0
	for s in range(len(arr)):
		if arr[s] == cur:
			cur += 1
	return cur
for j in range(int(input())):
	n = int(input())
	vals = list(map(int, input().split()))
	enc = set([])
	m1 = []
	m2 = []
	for s in range(n):
		if not vals[s] in enc:
			m1.append(vals[s])
			enc.add(vals[s])
		else:
			m2.append(vals[s])
	m1.sort()
	m2.sort()
	print(findmex(m1) + findmex(m2))


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac
from itertools import permutations as permu

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
num = 1
num = int(z())
for _ in range(num):
	n = int(z())
	arr = zzz()
	cnt = [0] * 103
	for i in arr:
		cnt[i] += 1
	ans = 0
	for i in range(102):
		if cnt[i] >= 1:
			continue
		else:
			ans = i
			break
	for i in range(102):
		if cnt[i] >= 2:
			continue
		else:
			ans += i
			break
	print(ans)


def mex(array):
	q = sorted(array)
	for i in range(len(array)):
		if i == q[i]:
			pass
		else:
			return i
	return len(array)
for _ in range(int(input())):
	a = int(input())
	b = list((int(x) for x in input().split()))
	c = list(set(b))
	for i in c:
		b.remove(i)
	b = list(set(b))
	print(mex(c) + mex(b))


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	a = [0] * 101
	for j in l:
		a[j] += 1
	mcnt = -1
	lcnt = -1
	for j in range(101):
		if a[j] < 2:
			if lcnt == -1:
				lcnt = j
			if a[j] == 0:
				mcnt = j
				break
	print(lcnt + mcnt)


from collections import defaultdict
t = int(input())
for i in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	ct = defaultdict(int)
	for x in A:
		ct[x] = ct[x] + 1
	ans = 0
	for i in range(101):
		if ct[i] == 0:
			ans += i
			break
		ct[i] -= 1
	for i in range(101):
		if ct[i] == 0:
			ans += i
			break
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	b = [0] * 101
	flag = 0
	ss = 0
	for i in a:
		b[i] += 1
	for i in range(101):
		if flag:
			if b[i] == 0:
				ss += i
				break
			else:
				continue
		elif b[i] == 0:
			ss = 2 * i
			break
		elif b[i] == 1:
			ss += i
			flag = 1
		else:
			continue
	print(ss)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	x = max(a) + 1
	count = [a.count(i) for i in range(x + 1)]
	ans = 0
	for i in range(len(count)):
		if count[i] > 0:
			count[i] -= 1
		else:
			ans += i
			break
	for i in range(len(count)):
		if count[i] > 0:
			count[i] -= 1
		else:
			ans += i
			break
	print(ans)


T = int(input().rstrip())

def get_mex(d):
	c = 0
	while True:
		if c not in d or d[c] == 0:
			return c
		d[c] -= 1
		c += 1

def solve(arr):
	nd = {}
	for i in arr:
		if i in nd:
			nd[i] += 1
		else:
			nd[i] = 1
	mex1 = get_mex(nd)
	mex2 = get_mex(nd)
	return mex1 + mex2
for test in range(T):
	n = int(input().rstrip())
	arr = [int(x) for x in input().rstrip().split()]
	ret = solve(arr)
	print(ret)


noOfTestCases = int(input())
for testCase in range(noOfTestCases):
	noOfElements = int(input())
	arr = [int(i) for i in input().split()]
	record = [0] * 101
	for i in range(noOfElements):
		record[arr[i]] += 1
	num1 = None
	num2 = None
	for i in range(101):
		if record[i] == 0:
			num1 = i
			if num2 is None:
				num2 = i
			break
		elif record[i] == 1:
			if num2 is None:
				num2 = i
		else:
			num1 = i
	print(num1 + num2)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	d = [0 for i in range(101)]
	for i in a:
		d[i] += 1
	cnt1 = 0
	for i in range(len(d)):
		if d[i] != 0:
			d[i] -= 1
			cnt1 = i + 1
		else:
			break
	cnt2 = 0
	for i in range(len(d)):
		if d[i] != 0:
			d[i] -= 1
			cnt2 = i + 1
		else:
			break
	print(cnt1 + cnt2)


t = int(input())
for tc in range(t):
	n = int(input())
	c = list(map(int, input().split()))
	c.sort()
	b = c
	a = []
	count = 0
	l = 0
	for i in range(101):
		if i in b:
			a.append(i)
			b.remove(i)
		else:
			break
	for mexA in range(102):
		if mexA not in a:
			break
	for mexB in range(102):
		if mexB not in b:
			break
	print(mexA + mexB)


def solver():
	t = int(input())
	for epoch in range(t):
		n = int(input())
		num = list(map(int, input().split()))
		index = [0 for i in range(110)]
		for s in num:
			index[s] += 1
		a = []
		b = []
		(ans, ok1, ok2) = (0, True, True)
		for i in range(len(index)):
			if index[i] >= 1:
				a.append(i)
			if index[i] >= 2:
				b.append(i)
		for i in range(len(index)):
			if ok1:
				if len(a) <= i or a[i] != i:
					ok1 = False
					ans += i
			if ok2:
				if len(b) <= i or b[i] != i:
					ok2 = False
					ans += i
		print(ans)
solver()


totLoop = int(input())
for x in range(totLoop):
	z = int(input())
	y = list(map(int, input().split()))
	y.sort()
	dict = {}
	for i in y:
		if str(i) in dict:
			dict[str(i)] += 1
		else:
			dict[str(i)] = 1
	listValue = list(dict.keys())
	mexA = 0
	mexB = 0
	checkVal = 0
	oneElementFlag = 0
	for p in listValue:
		if p != str(checkVal):
			break
		else:
			checkVal += 1
			if dict[p] > 1:
				mexA += 1
				if oneElementFlag != 1:
					mexB += 1
			else:
				oneElementFlag = 1
				mexA += 1
	print(mexA + mexB)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	n_arr = [arr.count(i) for i in range(max(arr) + 1)]
	if 1 in n_arr and 0 in n_arr:
		zero = n_arr.index(0)
		one = n_arr.index(1)
		a = zero
		b = one if one < zero else zero
	elif 1 not in n_arr and 0 in n_arr:
		zero = n_arr.index(0)
		a = zero
		b = zero
	elif 1 in n_arr and 0 not in n_arr:
		one = n_arr.index(1)
		a = max(arr) + 1
		b = one
	else:
		a = max(arr) + 1
		b = max(arr) + 1
	print(a + b)


t = int(input())
for i in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	freq = {}
	if 0 not in lst:
		print(0)
	else:
		for i in lst:
			if i in freq:
				freq[i] += 1
			else:
				freq[i] = 1
		ans = 0
		l1 = []
		l2 = []
		for (k, v) in freq.items():
			if v >= 2:
				l1.append(k)
				l2.append(k)
			elif v == 1:
				l1.append(k)
		ans = 0
		ans1 = 0
		if len(l1) != 0:
			ans = 0
			for i in range(len(l1) - 1):
				if l1[i + 1] - l1[i] != 1:
					ans += l1[i] + 1
					break
			if ans == 0:
				ans = l1[-1] + 1
		if len(l2) != 0 and l2[0] == 0:
			ans1 = 0
			for i in range(len(l2) - 1):
				if l2[i + 1] - l2[i] != 1:
					ans1 += l2[i] + 1
					break
			if ans1 == 0:
				ans1 = l2[-1] + 1
		elif len(l2) != 0 and l2[0] != 0:
			ans1 += 0
		print(ans + ans1)


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	lst1 = []
	lst2 = []
	for j in arr:
		if j in lst1:
			lst2.append(j)
		else:
			lst1.append(j)
	a = 0
	while a in lst1:
		a = a + 1
		if a == max(lst1) + 1:
			break
	mex1 = a
	b = 0
	while b in lst2:
		b = b + 1
		if b == max(lst2) + 1:
			break
	mex2 = b
	print(mex1 + mex2)


def range_input():
	return range(int(input()))

def map_int_input():
	return map(int, input().split())
for t in range_input():
	n = int(input())
	a = list(map_int_input())
	a.sort()
	val1 = -1
	val2 = -1
	for i in a:
		if i == val1 + 1:
			val1 += 1
		elif i == val2 + 1:
			val2 += 1
		elif i > val1 + 1:
			break
	val1 += 1
	val2 += 1
	print(val1 + val2)


def solution():
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	a = -1
	b = -1
	for i in range(len(l)):
		if l[i] in d:
			d[l[i]] += 1
		else:
			d[l[i]] = 1
	for i in range(0, n + 1):
		if i not in d:
			if a == -1:
				a = i
				b = i
			else:
				b = i
			break
		if i in d and d[i] == 1:
			if a == -1:
				a = i
	print(a + b)
t = int(input())
while t > 0:
	solution()
	t -= 1


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	dic = dict()
	ans = 0
	flag = 0
	for i in a:
		if i in dic:
			dic[i] = dic[i] + 1
		else:
			dic[i] = 1
	for i in range(max(a) + 2):
		if i not in dic:
			if flag == 0:
				ans = 2 * i
				break
			ans = ans + i
			break
		elif dic[i] == 1 and flag == 0:
			ans = ans + i
			flag = 1
	print(ans)
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ans = 0
	flag = 0
	ans = [0 for i in range(101)]
	for i in a:
		ans[i] += 1
	for i in range(len(ans)):
		if ans[i] >= 2 and flag == 0:
			continue
		elif ans[i] == 1 and flag == 0:
			cor = i
			flag = 1
		elif ans[i] == 0:
			if flag == 0:
				cor = i * 2
			else:
				cor += i
			break
	print(cor)


n1 = int(input())
for test in range(n1):
	n = int(input())
	set1 = [int(y) for y in input().split()]
	set1.sort()
	x = 0
	for j in range(2):
		cur = 0
		for i in range(len(set1)):
			if set1[i] == cur:
				cur = cur + 1
				set1[i] = -1
			elif set1[i] > cur:
				x = x + cur
				break
			if i == len(set1) - 1:
				x = x + cur
	print(x)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	for j in range(102):
		if l.count(j) >= 2:
			continue
		else:
			total = j
			for k in range(j, 102):
				if k in l:
					continue
				else:
					total += k
					break
			print(total)
			break


for _ in range(int(input())):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	ans = 0
	j = 0
	k = 0
	for i in range(n):
		if l.count(i) == 0:
			if j == 0:
				ans += 2 * i
				j += 2
				break
			else:
				ans += i
				j += 1
				k = 0
				break
		elif j == 1 and l.count(i) == 1:
			k = i + 1
		elif l.count(i) == 1:
			j += 1
			ans += i
		if j == 2:
			break
	if n == 1 and l[0] == 0:
		k = 1
	print(ans + k)


def mex(arr):
	tmp = [0] * 101
	for i in arr:
		tmp[i] = 1
	for i in range(102):
		if tmp[i] == 0:
			return i
	return 0
for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	(A, B) = ([], [])
	for i in lis:
		if i not in A:
			A.append(i)
		else:
			B.append(i)
	print(mex(A) + mex(B))
	continue


import collections

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
t = inp()
for _ in range(t):
	n = inp()
	l = inlt()
	(a, b) = (set(), set())
	for num in l:
		if num not in a:
			a.add(num)
		else:
			b.add(num)
	res = 0
	afound = bfound = False
	for i in range(0, 101):
		if not afound and i not in a:
			res += i
			afound = True
		if not bfound and i not in b:
			res += i
			bfound = True
		if afound and bfound:
			print(res)
			break


t = int(input())
for _ in range(t):
	length = int(input())
	array = [int(i) for i in input().split()]
	if 0 not in array:
		print(0)
	else:
		new_array = list()
		new_array.append(0)
		array.remove(0)
		for i in range(1, length + 1):
			if i in array:
				new_array.append(i)
				array.remove(i)
			else:
				break
		newarray2 = list()
		for i in range(length + 1):
			if i in array:
				newarray2.append(i)
				array.remove(i)
			else:
				break
		ans = 0
		for i in range(length + 1):
			if i not in new_array:
				ans += i
				break
		for i in range(length + 1):
			if i not in newarray2:
				ans += i
				break
		print(ans)


def mex(A):
	if A == []:
		return 0
	for i in range(max(A) + 2):
		if i not in A:
			return i
t = int(input())
for _ in range(t):
	n = int(input())
	S = list(map(int, input().split()))
	if 0 not in S:
		print(0)
		continue
	if S.count(0) == 1:
		print(mex(S))
		continue
	adict = {}
	for i in S:
		if i in adict:
			adict[i] += 1
		else:
			adict[i] = 1
	A = []
	B = []
	values = sorted(list(adict.keys()))
	for i in values:
		if adict[i] > 1:
			A = A + [i] * (adict[i] // 2)
			B = B + [i] * (adict[i] - adict[i] // 2)
		elif mex(A + [i]) > mex(A):
			A.append(i)
		else:
			B.append(i)
	print(mex(A) + mex(B))


import sys
import math
import collections
import bisect
import itertools
import decimal
import copy
import heapq
INF = 10 ** 20
MOD = 10 ** 9 + 7
ni = lambda : int(sys.stdin.readline().rstrip())
ns = lambda : map(int, sys.stdin.readline().rstrip().split())
na = lambda : list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda : list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))
flush = lambda : sys.stdout.flush()

def main():
	t = ni()
	for _ in range(t):
		n = ni()
		a = na()
		c = collections.Counter(a)
		x = -1
		y = -1
		bflg = True
		for i in range(max(a) + 1):
			if i in c.keys():
				if c[i] >= 2:
					x = i
					if bflg:
						y = i
				elif c[i] >= 1:
					x = i
					bflg = False
			else:
				break
		x += 1
		y += 1
		print(x + y)
main()


def mex(t):
	t.sort()
	if len(t) == 0:
		return 0
	for j in range(0, len(t)):
		if t[j] != j:
			return j
	if t[len(t) - 1] != len(t):
		return len(t)
	else:
		return 0
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	A = list()
	B = list()
	a.sort()
	for i in range(len(a)):
		for j in range(i + 1, len(a)):
			if a[i] == a[j]:
				B.append(a[i])
				break
			else:
				continue
	a = set(a)
	A = set(A)
	B = set(B)
	A = a - B
	A = A | B
	p = mex(list(A))
	q = mex(list(B))
	print(p + q)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	dic = {}
	for d in arr:
		if d not in dic:
			dic[d] = 0
		dic[d] += 1
	fl = 0
	x = 0
	y = 1000
	for i in range(0, 102):
		if i not in dic:
			if fl == 1:
				x = i
				break
			if fl == 0:
				x = i
				y = i
			break
		elif dic[i] == 1:
			if y == 1000:
				y = i
			fl = 1
	print(x + y)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	f = 0
	som = 0
	for i in range(0, 101):
		if l.count(i) == 0:
			if f == 1:
				som = som + i
			else:
				som = som + i + i
			break
		if l.count(i) == 1 and f == 0:
			som = som + i
			f = 1
	print(som)


for _ in range(int(input())):
	a = {x: 0 for x in range(101)}
	n = int(input())
	l = list(map(int, input().split()))
	for i in l:
		a[i] += 1
	ans = 0
	i = 0
	while True:
		if a[i] == 0:
			ans += i
			break
		i += 1
	i = 0
	while True:
		if a[i] <= 1:
			ans += i
			break
		i += 1
	print(ans)


for i in range(int(input())):
	n = int(input())
	list1 = list(map(int, input().split()))
	a = sorted(list1)
	min_a = a[0]
	ans1 = 100
	ans2 = 100
	c = {}
	for k in range(0, 101):
		c[k] = 0
	for b in a:
		c[b] += 1
	for k in range(0, 101):
		if c[k] == 0:
			ans1 = min(k, ans1)
			break
		else:
			c[k] -= 1
	for k in range(0, 101):
		if c[k] == 0:
			ans2 = min(k, ans2)
			break
		else:
			c[k] -= 1
	ans = ans2 + ans1
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	A = []
	B = []
	ans = 0
	count = 0
	for i in a:
		if i not in A:
			A.append(i)
		else:
			B.append(i)
	for i in range(n + 1):
		if i not in A:
			ans += i
			break
	for i in range(n + 1):
		if i not in B:
			ans += i
			break
	print(ans)


def get(l):
	i = 0
	j = 0
	both = True
	count = 1
	for (k, x) in enumerate(l):
		if k == 0:
			if x != 0:
				return 0
			else:
				i += 1
		else:
			if l[k] != l[k - 1]:
				if l[k] != l[k - 1] + 1:
					return i + j
				if count == 1:
					both = False
				count = 1
			else:
				count += 1
			if count == 1:
				i += 1
			elif count == 2 and both:
				j += 1
	return i + j
t = int(input())
for i in range(t):
	n = int(input())
	l = sorted([int(x) for x in input().split()])
	print(get(l))


def solution(val):
	ans = []
	for i in range(0, len(val)):
		a = val[i]
		a.sort()
		mex = 0
		count = 0
		for j in range(0, len(a) + 1):
			r = 2 - count
			for k in range(0, r):
				if j in a:
					a.remove(j)
				elif count < 2:
					mex += j
					count += 1
					if count == 2:
						ans.append(mex)
						break
			if count == 2:
				break
	return ans

def main():
	n = int(input())
	l = []
	for i in range(0, n):
		p = int(input())
		num = list(map(int, input().split()))
		l.append(num)
	result = solution(l)
	for i in range(0, len(result)):
		print(result[i])
main()


for _ in range(int(input())):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	a = [0]
	b = [-1]
	bool = False
	if l[0] != 0:
		print(0)
	else:
		for num in range(n):
			if abs(l[num] - a[-1]) <= 1:
				if l.count(l[num]) < 2:
					a.append(l[num])
					bool = True
				elif bool == False:
					a.append(l[num])
					b.append(l[num])
				else:
					a.append(l[num])
			else:
				break
		print(max(a) + 1 + max(b) + 1)


def subsetMax(arr, n):
	countDict = {}
	setA = set()
	setB = set()
	setC = set([i for i in range(101)])
	for i in range(n):
		if arr[i] not in setA:
			setA.add(arr[i])
		elif arr[i] not in setB:
			setB.add(arr[i])
	remA = min(setC - setC.intersection(setA))
	remB = min(setC - setC.intersection(setB))
	return remA + remB
testCases = input()
for i in range(int(testCases)):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = subsetMax(arr, n)
	print(ans)


for l in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	(a, b) = (0, 0)
	arr.sort()
	for i in arr:
		if a == i:
			a += 1
		elif b == i:
			b += 1
	print(a + b)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(A, B) = ([], [])
	for i in a:
		if i not in A:
			A.append(i)
		else:
			B.append(i)
	s = 0
	if len(A) != 0:
		for i in range(max(A) + 2):
			if i not in A:
				s += i
				break
	if len(B) != 0:
		for i in range(max(B) + 2):
			if i not in B:
				s += i
				break
	print(s)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	(left, right) = (set(), set())
	for num in arr:
		if num not in left:
			left.add(num)
		else:
			right.add(num)
	mexA = mexB = 0
	for num in range(101):
		if num not in left:
			mexA = num
			break
	for num in range(101):
		if num not in right:
			mexB = num
			break
	ans = mexB + mexA
	print(ans)


def Input():
	Str = input('')
	List = Str.split(' ')
	for i in range(len(List)):
		List[i] = int(List[i])
	return List

def Twice(List, n):
	Count = 0
	for i in range(len(List)):
		if List[i] == n:
			Count += 1
		if Count == 2:
			break
	return Count

def Mex(List):
	N = 0
	Done = False
	while Done == False:
		x = Twice(List, N)
		if x == 0 or x == 1:
			Done = True
		else:
			N += 1
	M = N
	if x != 0:
		Done = False
		N += 1
	while Done == False:
		x = Twice(List, N)
		if x == 0:
			Done = True
		else:
			N += 1
	return M + N
trials = int(input(''))
for i in range(trials):
	input('')
	List = Input()
	print(Mex(List))


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def solve():
	n = mint()
	b = [0] * 101
	for i in mints():
		b[i] += 1
	a = 0
	for j in range(101):
		if b[j] >= 2:
			a = j + 1
		else:
			break
	c = 0
	for j in range(101):
		if b[j] >= 1:
			c = j + 1
		else:
			break
	print(a + c)
for i in range(mint()):
	solve()


t = int(input())
for test in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	arr.sort()
	hashmap = {}
	first = []
	second = []
	for i in arr:
		if i in hashmap:
			second.append(i)
		else:
			first.append(i)
			hashmap[i] = 0
	mina = 0
	minb = 0
	second = list(set(second))
	for (ind, val) in enumerate(first):
		if ind != val:
			mina = ind
			break
		else:
			mina += 1
	for (ind, val) in enumerate(second):
		if ind != val:
			minb = ind
			break
		else:
			minb += 1
	print(mina + minb)


inputed = []
count = int(input())
linesPer = 2
for i in range(count * linesPer):
	inputed.append(input())
for i in range(count):
	try:
		inputed[1] = inputed[1].split(' ')
		inputed[1] = [int(x) for x in inputed[1]]
		countArr = [0 for x in inputed[1]]
		maxA = 0
		maxB = 0
		for x in inputed[1]:
			if x < len(countArr):
				countArr[x] += 1
		for i in range(len(countArr)):
			if countArr[i] > 0:
				maxA += 1
				countArr[i] -= 1
			else:
				break
		for i in range(len(countArr)):
			if countArr[i] > 0:
				maxB += 1
			else:
				break
		print(maxA + maxB)
	except:
		print(0)
	for i in range(linesPer):
		del inputed[0]


for _ in range(int(input())):
	n = int(input())
	a = sorted(map(int, input().split()))
	c0 = c1 = 0
	for i in a:
		if c0 == i:
			c0 += 1
			continue
		if c1 == i:
			c1 += 1
	print(c0 + c1)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	m = [0 for i in range(101)]
	for i in a:
		m[i] += 1
	(f, s) = (0, 0)
	flag = True
	for k in range(101):
		if m[k] >= 2:
			if flag:
				f += 1
			s += 1
		elif m[k] == 1:
			f += 1
			flag = False
		else:
			break
	print(f + s)


from collections import defaultdict
t = int(input())
while t > 0:
	n = int(input())
	a = [int(i) for i in input().split()]
	d = defaultdict(int)
	for i in a:
		d[i] += 1
	ans = 0
	count = 0
	for i in range(110):
		if d[i] >= 1:
			d[i] -= 1
		else:
			ans += i
			break
	for i in range(110):
		if d[i] >= 1:
			d[i] -= 1
		else:
			ans += i
			break
	print(ans)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	x = y = i = 0
	while i in l:
		l.remove(i)
		i += 1
	x = i
	i = 0
	while i in l:
		i += 1
	y = i
	i = 0
	print(x + y)


for t in range(int(input())):
	n = int(input())
	a = sorted(map(int, input().split()), reverse=True)
	(A, B) = ([], [])
	other = []
	A = list(set(a))
	for i in A:
		del a[a.index(i)]
	B = a
	for numa in range(101):
		if not numa in A:
			break
	for numb in range(101):
		if not numb in B:
			break
	print(numa + numb)


n = int(input().strip())
for i in range(n):
	k = int(input().strip())
	all = [int(i) for i in input().strip().split()]
	total = {}
	for i in all:
		total[i] = total.get(i, 0) + 1
	resa = 0
	resb = 0
	for i in range(101):
		if i in total and total[resa]:
			total[resa] -= 1
			resa += 1
		else:
			break
	for i in range(101):
		if i in total and total[resb]:
			total[resb] -= 1
			resb += 1
		else:
			break
	print(resa + resb)


def solve(lst):
	lst = sorted(lst)
	new = []
	for i in range(len(lst) - 1):
		if lst[i] == lst[i + 1]:
			new.append(lst[i])
	new = sorted(list(set(new)))
	lst = sorted(list(set(lst)))
	a = 0
	b = 0
	mex1 = 0
	mex2 = 0
	while mex1 in new:
		mex1 += 1
		a += 1
	while mex2 in lst:
		mex2 += 1
		b += 1
	return a + b
k = int(input())
for i in range(k):
	m = int(input())
	lst = list(map(int, input().split()))
	print(solve(lst))


mod = int(1000000000.0) + 7

def sp(n):
	if n == 1:
		return input()
	else:
		return map(str, input().split())

def np(n):
	if n == 1:
		return int(input())
	else:
		return map(int, input().split())
for _ in range(0, int(input())):
	n = np(1)
	l = list(np(2))
	(a, b) = ([], [])
	for i in l:
		if i not in a:
			a.append(i)
		else:
			b.append(i)
	ans = 0
	for i in range(0, 101):
		if i not in a:
			ans += i
			break
	for i in range(0, 101):
		if i not in b:
			ans += i
			break
	print(ans)


def solve(n, ar):
	ar = sorted(ar)
	freq = [0] * 101
	for i in range(n):
		freq[ar[i]] += 1
	b = 0
	for i in range(len(freq)):
		if freq[i] >= 2:
			continue
		else:
			b = i
			break
	a = 0
	for i in range(len(freq)):
		if freq[i] == 0:
			a = i
			break
	print(a + b)
t = int(input())
for _ in range(t):
	n = int(input())
	ar = list(map(int, input().split()))
	solve(n, ar)


from collections import Counter as C
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	cnts = C(a)
	mex0 = 0
	mex1 = 0
	b = 2
	for i in range(101):
		if cnts[i] == 0:
			break
		mex0 += 1
		if cnts[i] == 1:
			b = 1
		if b == 2:
			mex1 += 1
	print(mex0 + mex1)


t = int(input())
i = 0
while i < t:
	n = int(input())
	a = list(map(int, input().split()))
	A = [0] * 101
	Am = -1
	Bm = -1
	for j in a:
		A[j] += 1
	index = 0
	while True:
		while A[index] >= 2:
			Am = index
			Bm = index
			index += 1
		while A[index] >= 1:
			Am = index
			index += 1
		print(Am + Bm + 2)
		break
	i += 1


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = set(l)
	if len(s) == n:
		for i in range(0, 101):
			if i not in s:
				print(i)
				break
	else:
		s1 = set()
		s2 = set()
		for i in l:
			if i not in s1:
				s1.add(i)
			else:
				s2.add(i)
		for i in range(0, 101):
			if i not in s1:
				m1 = i
				break
		for i in range(0, 101):
			if i not in s2:
				m2 = i
				break
		print(m1 + m2)


from collections import Counter
t = int(input())
for _ in range(t):
	input()
	counts = Counter(map(int, input().split()))
	ans = 0
	now = 0
	max_c = 2
	while now in counts:
		max_c = min(max_c, counts[now])
		ans += max_c
		now += 1
	print(ans)


t = int(input())
for you in range(t):
	n = int(input())
	l = input().split()
	li = [int(i) for i in l]
	arr = [0 for i in range(105)]
	for i in li:
		arr[i] += 1
	ans = 0
	done1 = 0
	done2 = 0
	for i in range(105):
		if done1 == 0 and done2 == 0:
			if arr[i] == 0:
				ans = 2 * i
				break
			if arr[i] == 1:
				ans += i
				done1 = 1
		if done1 == 1:
			if arr[i] == 0:
				ans += i
				break
	print(ans)


from collections import Counter, defaultdict
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = Counter(a)
	mex = 0
	b = set(a)
	for i in range(101):
		if i not in b:
			mex += i
			break
	for i in range(101):
		if d[i] < 2:
			mex += i
			break
	print(mex)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from bisect import insort
from collections import Counter
from collections import deque
from heapq import heappush, heappop, heapify
from itertools import permutations, combinations
mod = int(1000000000.0) + 7
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
out = lambda x: stdout.write(str(x) + '\n')
t = ip()
for _ in range(t):
	n = ip()
	arr = list(inp())
	dic = Counter(arr)
	ch = list(dic.keys())
	ch.sort()
	(mex1, mex2) = (0, 0)
	flag = True
	ideal = [i for i in range(101)]
	for i in ideal:
		if dic[i] >= 2 and flag:
			mex1 += 1
			mex2 += 1
		else:
			flag = False
			if dic[i] >= 1:
				mex1 += 1
			else:
				break
	ans = mex1 + mex2
	out(ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	i = 0
	while i <= max(a) and a.count(i) > 1:
		i += 1
	j = 0
	while j <= max(a) and j + 1 in a:
		j += 1
	if 0 not in a:
		print(0)
	else:
		print(i + j + 1)


import sys
sys.setrecursionlimit(10 ** 8)
try:
	FILE_POINTER = open('input.inpt')
	input = FILE_POINTER.readline
except:
	FILE_POINTER = None
	input = sys.stdin.readline
from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().strip().split()))
	num1 = num2 = 0
	d = Counter(arr)
	flag = 1
	for i in range(101):
		if i in d:
			if d[i] >= 2:
				num1 += 1
				if flag:
					num2 += 1
				continue
			elif d[i] == 1:
				num1 += 1
				flag = 0
			else:
				break
		else:
			break
	print(num1 + num2)
if FILE_POINTER:
	FILE_POINTER.close()


t = int(input())
while t > 0:
	n = int(input())
	arr = list(map(int, input().split(' ')))
	arr.sort()
	mexA = set()
	mexB = set()
	for i in range(n):
		if arr[i] not in mexA:
			mexA.add(arr[i])
		else:
			mexB.add(arr[i])
	s = 0
	for (id, val) in enumerate(mexA):
		if id != val:
			s += id
			break
	else:
		s += len(mexA)
	for (id, val) in enumerate(mexB):
		if id != val:
			s += id
			break
	else:
		s += len(mexB)
	print(s)
	t -= 1


n = int(input())
for i in range(n):
	a = [0] * 102
	m = int(input())
	for j in input().split():
		a[int(j)] += 1
	s = 0
	ll = 0
	ink = 0
	f = True
	while a[ll] != 0:
		if a[ll] == 1 and f == True:
			ink = ll
			f = False
		ll += 1
	if f == True:
		s = ll + ll
	else:
		s = ink + ll
	print(s)


for _ in range(int(input())):
	n = int(input())
	num = list(map(int, input().split()))
	num.sort()
	a = [0] * 101
	b = [0] * 101
	for i in range(len(num)):
		if a[num[i]] == 0:
			a[num[i]] = 1
		else:
			b[num[i]] = 1
	answer = 0
	for i in range(101):
		if a[i] == 1:
			continue
		else:
			answer += i
			break
	for i in range(101):
		if b[i] == 1:
			continue
		else:
			answer += i
			break
	print(answer)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	mex1 = 0
	for i in range(102):
		for j in range(n):
			if arr[j] == mex1:
				mex1 += 1
				arr[j] = -1
				break
	mex2 = 0
	for i in range(102):
		for j in range(n):
			if arr[j] == mex2:
				mex2 += 1
				arr[j] = -1
				break
	print(str(mex1 + mex2))


t = int(input())
while t != 0:
	n = int(input())
	a = list(map(int, input().split()))[:n]
	net = [0] * 101
	for i in set(a):
		net[i] = a.count(i)
	for j in range(len(net)):
		if net[j] == 0:
			x = j
			break
		net[j] -= 1
	for k in range(len(net)):
		if net[k] == 0:
			y = k
			break
		net[k] -= 1
	print(x + y)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	from collections import Counter
	d = {i: 0 for i in range(101)}
	d1 = Counter(l)
	for i in d1.keys():
		d[i] = d1[i]
	count = 0
	x = 0
	for (i, j) in d.items():
		if x >= 1:
			break
		if j == 0:
			count += i
			x += 1
	x = 0
	for (i, j) in d.items():
		if x >= 1:
			break
		if j <= 1:
			count += i
			x += 1
	print(count)


cases = int(input(''))
list1 = []
list2 = []
output = []
mex = 0
flag = 0
for case in range(cases):
	size = int(input(''))
	x = input('').split()
	if size == 1:
		if int(x[0]) == 0:
			output.append(1)
			continue
		else:
			output.append(0)
			continue
	if size == 2 and x[0] == '0' and (x[1] == '0'):
		output.append(2)
		continue
	for c in range(size):
		list1.append(int(x[c]))
	list1.sort()
	for c in range(size - 1):
		if list1[c] == list1[c + 1]:
			list2.append(list1[c])
	list2 = set(list2)
	list1 = set(list1)
	list2 = list(list2)
	list1 = list(list1)
	list1.sort()
	list2.sort()
	for c in range(105):
		if list1[c] != c:
			mex += c
			break
		if c == len(list1) - 1:
			mex += list1[len(list1) - 1] + 1
			break
	for z in range(105):
		if len(list2) == 0:
			break
		if list2[z] != z:
			mex += z
			break
		if z == len(list2) - 1:
			mex += list2[len(list2) - 1] + 1
			break
	output.append(mex)
	mex = 0
	list1 = []
	list2 = []
	flag = 0
print(*output, sep='\n')


from collections import defaultdict
from collections import Counter
import math

def solve(n, A):
	m = max(A)
	ans = 0
	freq = Counter(A)
	fa = [0] * 110
	for (i, v) in freq.items():
		fa[i] = v
	k = 2
	while k != 0:
		i = 0
		while fa[i] != 0:
			fa[i] -= 1
			i += 1
		ans += i
		k -= 1
	return ans
t = int(input())
while t:
	res = []
	n = int(input())
	in_ = map(int, input().split(' '))
	for x in in_:
		res.append(int(x))
	print(solve(n, res))
	t -= 1


from collections import defaultdict
T = int(input())

def mex(A):
	A = set(A)
	for i in range(102):
		if i not in A:
			return i
for t in range(T):
	n = int(input())
	A = [int(i) for i in input().split()]
	d = defaultdict(int)
	for i in A:
		d[i] += 1
	first = 0
	second = 0
	second_fix = False
	for i in range(102):
		if d[i] < 2 and (not second_fix):
			second = i
			second_fix = True
		if d[i] < 1:
			first = i
			break
	print(first + second)


for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	a = -1
	b = -1
	for i in range(n):
		if l[i] == a + 1:
			a = a + 1
			l[i] = -1
	for i in range(n):
		if l[i] == -1:
			pass
		elif l[i] == b + 1:
			b = b + 1
	print(a + 1 + b + 1)


for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	a = [0] * (max(l) + 2)
	b = [0] * len(a)
	for i in l:
		if a[i] < 1:
			a[i] += 1
		else:
			b[i] += 1
	print(a.index(0) + b.index(0))


from collections import deque
from math import ceil
import sys
for _ in range(int(input())):
	n = int(input())
	a = {}
	for i in range(103):
		a[i] = 0
	for i in input().split():
		a[int(i)] += 1
	j = 0
	ans = 0
	while a[j] > 1:
		ans += 2
		j += 1
	while a[j] > 0:
		ans += 1
		j += 1
	print(ans)


def main(n, arr):
	(val1, val2) = (0, n)
	for i in range(n):
		if arr.count(i) < 2:
			val1 = i
			break
	for i in range(n):
		if arr.count(i) == 0:
			val2 = i
			break
	return val1 + val2
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	val = main(n, arr)
	print(val)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	l = [0] * 102
	for k in a:
		l[k] += 1
	ans = -1
	for i in range(102):
		if l[i] <= 1 and ans == -1:
			if l[i] == 1:
				ans += i + 1
			else:
				ans = 2 * i
				break
		elif not l[i]:
			ans += i
			break
	if ans == -1:
		ans = 0
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	a.sort()
	(x, y) = (0, 0)
	for i in range(n):
		if i in a:
			a.remove(i)
			if i == n - 1:
				x = i + 1
		else:
			x = i
			break
	m = len(a)
	for j in range(m):
		if j in a:
			a.remove(j)
			if j == m - 1:
				y = j + 1
		else:
			y = j
			break
	print(x + y)


from sys import stdin, stdout
st = lambda : list(stdin.readline().strip())
li = lambda : list(map(int, stdin.readline().split()))
mp = lambda : map(int, stdin.readline().split())
inp = lambda : int(stdin.readline())
pr = lambda n: stdout.write(str(n) + '\n')
mod = 1000000007

def solve():
	n = inp()
	l = li()
	s = set(l)
	if len(s) != n:
		(x, y) = (set(), set())
		for i in l:
			if i in x:
				y.add(i)
			else:
				x.add(i)
		for i in range(101):
			if i not in x:
				val = i
				break
		for i in range(101):
			if i not in y:
				vall = i
				break
		pr(val + vall)
	else:
		for i in range(101):
			if i not in s:
				pr(i)
				break
for _ in range(inp()):
	solve()


for _ in range(int(input())):
	n = int(input())
	c = [0] * 101
	for i in map(int, input().split()):
		c[i] += 1
	s = 0
	z = 1
	v = 1
	for i in range(101):
		if z and c[i] == 0:
			s += i
			z = 0
		if v and c[i] <= 1:
			s += i
			v = 0
		if not z and (not v):
			break
	print(s)


for case in range(int(input())):
	N = int(input())
	arr = list(map(int, input().split()))
	arr.sort
	tally = 0
	lowest = None
	highest = None
	while highest == None:
		if arr.count(tally) == 0:
			highest = tally
		tally += 1
	tally = 0
	while lowest == None:
		if arr.count(tally) < 2:
			lowest = tally
		tally += 1
	print(highest + lowest)


import collections
t = int(input())
for _ in range(t):
	n = int(input())
	a = sorted(list(map(int, input().split())))

	def solve(a):
		A = collections.Counter(a)
		a1 = -1
		if A[0] == 0:
			return 0
		elif A[0] == 1:
			a1 = 0
		for i in range(len(A) + 2):
			if A[i] == 0:
				a2 = i
				if a1 == -1:
					return a2 * 2
				else:
					return a1 + a2
			elif A[i] == 1 and a1 == -1:
				a1 = i
	print(solve(a))


cases = int(input())
for case in range(cases):
	n = int(input())
	l = [int(s) for s in input().split()]
	end = max(l) + 2
	d = {}
	for i in range(end):
		d[i] = 0
	for k in l:
		d[k] += 1
	m1 = 0
	m2 = 0
	for i in range(end):
		if d[i] < 1:
			m1 = i
			break
	for i in range(end):
		if d[i] < 2:
			m2 = i
			break
	print(max(0, m1) + max(0, m2))


from collections import Counter
T = int(input())
for t in range(T):
	n = int(input())
	S = list(map(int, input().split()))
	Sd = Counter()
	for i in S:
		Sd[i] += 1
	mA = 0
	while Sd[mA]:
		Sd[mA] -= 1
		mA += 1
	mB = 0
	while Sd[mB]:
		Sd[mB] -= 1
		mB += 1
	print(mA + mB)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(result, got) = (0, 0)
	(x, r) = (True, True)
	for i in range(max(a) + 2):
		if x == True and a.count(i) <= 1:
			got = i
			x = False
		if r == True and i not in a:
			result = i
			r = False
	print(got + result)


for t in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	a = [0] * 102
	b = [0] * 102
	s.sort()
	for i in s:
		if a[i] == 0:
			a[i] += 1
		else:
			b[i] += 1
	print(a.index(0) + b.index(0))


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop, heapify
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
from itertools import accumulate
from functools import lru_cache
M = mod = 998244353

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
for _ in range(val()):
	n = val()
	l = sorted(li())
	a1 = set()
	a2 = set()
	for i in l:
		if i in a1:
			a2.add(i)
		else:
			a1.add(i)
	ans = 0
	for i in range(200):
		if i not in a1:
			ans += i
			break
	for i in range(200):
		if i not in a2:
			ans += i
			break
	print(ans)


t = int(input())
while t:
	n = int(input())
	a = [int(i) for i in input().split()]
	x = [-1] * 101
	y = [-1] * 101
	mem = {ele: 0 for ele in a}
	for ele in a:
		mem[ele] += 1
	for i in mem.keys():
		if mem[i] > 1:
			x[i] += 1
			y[i] += 1
		else:
			x[i] += 1
	mex1 = max(a) + 1
	mex2 = max(a) + 1
	for i in range(101):
		if x[i] < 0:
			mex1 = i
			break
	for i in range(101):
		if y[i] < 0:
			mex2 = i
			break
	print(mex1 + mex2)
	t -= 1


for x in range(int(input())):
	n = int(input())
	m = list(map(int, input().split()))
	d = [0] * 101
	for i in range(n):
		d[m[i]] += 1
	a = []
	for i in range(101):
		if d[i] == 1 and len(a) == 0:
			a.append(i)
		elif d[i] == 0:
			a.extend([i, i])
		if len(a) >= 2:
			break
	print(sum(a[:2]))


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr = sorted(arr)
	a_high = -1
	b_high = -1
	for ele in range(len(arr)):
		if arr[ele] == a_high + 1:
			a_high += 1
		elif arr[ele] == a_high:
			if arr[ele] == b_high + 1:
				b_high += 1
			else:
				pass
		else:
			break
	print(a_high + b_high + 2)


a = int(input())
for i in range(0, a):
	b = int(input())
	arr = list(map(int, input().split()))
	d = dict()
	for i in arr:
		d[i] = 0
	for i in arr:
		d[i] = d[i] + 1
	a1 = []
	a2 = []
	for i in range(0, max(arr) + 1):
		if i in d:
			if d[i] < 2:
				a1.append(i)
			else:
				a2.append(i)
				a1.append(i)
		else:
			break
	an1 = 0
	for i in range(0, max(arr) + 3):
		if i not in a1:
			an1 = i
			break
	an2 = 0
	for i in range(0, max(arr) + 3):
		if i not in a2:
			an2 = i
			break
	print(an1 + an2)


t = int(input())
for j in range(t):
	n = int(input())
	ar = [int(k) for k in input().split()]
	dic = {}
	for k in ar:
		try:
			dic[k] += 1
		except:
			dic[k] = 1
	i = 0
	mexa = None
	while i < 10000:
		if i in dic and dic[i] > 1:
			i += 1
		else:
			mexa = i
			break
	while i in dic and i < 1000:
		i += 1
	print(mexa + i)


cases = int(input())
for i in range(cases):
	answer = 0
	length = int(input())
	intlist = list(map(int, input().split()))
	intlist.sort()
	for a in range(length + 1):
		if a in intlist:
			intlist.remove(a)
		else:
			answer += a
			break
	for j in range(length + 1):
		if j in intlist:
			intlist.remove(j)
		else:
			answer += j
			break
	print(str(answer))


for _ in range(int(input())):
	n = int(input())
	x = sorted(list(map(int, input().split())))
	(a, b) = ([], [])
	ans = 0
	for i in x:
		if i not in a:
			a.append(i)
		else:
			b.append(i)
	if a:
		for i in range(max(a) + 2):
			if i not in a:
				ans += i
				break
	if b:
		for i in range(max(b) + 2):
			if i not in b:
				ans += i
				break
	print(ans)


def mex(l):
	if len(l) == 1:
		if l[0] > 0:
			return 0
		else:
			return 1
	c = [0] * (max(l) + 1)
	for i in l:
		c[i] += 1
	if c[0] == 0:
		return 0
	elif c[0] == 1:
		flag = 0
		for i in range(len(c)):
			if c[i] == 0:
				return i
		if flag == 0:
			return max(l) + 1
	else:
		count = 0
		res = 0
		for i in c:
			if i < 2:
				break
			elif count == len(c) - 1 and i >= 2:
				return 2 * (max(l) + 1)
			count += 1
		count = 0
		for i in range(len(c)):
			if c[i] == 0 and count == 0:
				return 2 * i
			elif c[i] == 1 and count == 0:
				res = res + i
				count += 1
			elif c[i] == 0 and count == 1:
				res = res + i
				count += 1
		if count == 1:
			return res + max(l) + 1
		return res
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	print(mex(l))


I = lambda : list(map(int, input().split()))
for _ in range(int(input())):
	n = int(input())
	a = I()
	i = 0
	while a.count(i) > 1:
		i = i + 1
	m2 = i
	while a.count(i) > 0:
		i = i + 1
	print(m2 + i)


from __future__ import division, print_function
INF = 10 ** 10
TEST_CASES = True
from collections import defaultdict, deque, Counter

def main():
	n = get_int()
	li = get_list()
	cnt = Counter(li)
	(s1, s2) = (-1, -1)
	for i in range(0, 10 ** 10):
		if s1 != -1 and i not in cnt:
			s2 = i
			break
		elif s1 == -1:
			if i in cnt:
				if cnt[i] == 1:
					s1 = i
			else:
				(s1, s2) = (i, i)
				break
	print(s1 + s2)
import os
import sys
from bisect import bisect_left, bisect_right, bisect
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
get_int = lambda : int(input())
get_list = lambda : list(map(int, input().split()))
if TEST_CASES:
	[main() for _ in range(int(input()))]
else:
	main()


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr_d = {}
	for elem in arr:
		arr_d[elem] = arr_d.get(elem, 0) + 1
	mexs = -1
	isconti = True
	for i in range(101):
		count = arr_d.get(i, 0)
		if count == 0:
			if mexs == -1:
				mexs = 2 * i
			else:
				mexs += i
			break
		if count == 1:
			if mexs == -1:
				mexs = i
			elif isconti:
				continue
			else:
				mexs += i
				break
		if count == 0:
			isconti = False
	print(mexs)


def mex(a):
	if not a:
		return 0
	for i in range(max(a) + 2):
		if i not in a:
			return i

def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		(s1, s2) = (set(), set())
		a = sorted(a)
		for i in range(n):
			if a[i] not in s1:
				s1.add(a[i])
			else:
				s2.add(a[i])
		print(mex(s1) + mex(s2))
main()


test = int(input())
for i in range(test):
	leng = int(input())
	inp = list(map(int, input().split(' ')))
	out = []
	if 0 in inp:
		for j in range(101):
			if j in inp:
				inp.remove(j)
			else:
				out.append(j)
				break
	else:
		out.append(0)
	if 0 in inp:
		for j in range(101):
			if j in inp:
				inp.remove(j)
			else:
				out.append(j)
				break
	else:
		out.append(0)
	print(out[0] + out[1])


for _ in range(int(input())):
	ans = 0
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	d = list(set(a))
	f = 0
	for i in range(len(d)):
		if i == d[i]:
			for j in range(len(a)):
				if a[j] == i:
					a.pop(j)
					break
			continue
		else:
			f = 1
			ans += i
			break
	if f == 0:
		ans += i + 1
	d = list(set(a))
	f = 0
	for i in range(len(d)):
		if i == d[i]:
			continue
		else:
			f = 1
			ans += i
			break
	if f == 0 and len(d) != 0:
		ans += i + 1
	print(ans)


import sys
import math
mod = 998244353
cases = True
dynamic_factorial = False

def main(test_case=False):
	n = int(input()) if test_case else 1
	for _ in range(n):
		test()
		print()

def fast_pow(a: int, b: int):
	res = 1
	while b > 0:
		if b & 1:
			res *= a
		a *= a
		b >>= 1
	return res

def c2(n):
	return n * (n - 1) // 2

def get():
	return list(map(int, input().split()))

def bits(n: int):
	return list(bin(n)).count('1')

def flush():
	sys.stdout.flush()

def parr(arr):
	print(*arr, sep=' ')

def gcd(a, b):
	while b:
		if b % a == 0:
			break
		tmp = a
		a = b % a
		b = tmp
	return a

def ext_gcd(a: int, b: int):
	if b == 0:
		return [a, [1, 0]]
	res = ext_gcd(b, a % b)
	g = res[0]
	if g != 1:
		return False
	x1 = res[1][0]
	y1 = res[1][1]
	x = y1
	y = x1 - y1 * (a // b)
	return [g, [x, y]]

def get_set(a):
	res = {}
	for x in a:
		if x in res:
			res[x] += 1
		else:
			res[x] = 1
	return res
fact = {0: 1}

def factorial(n):
	if dynamic_factorial:
		if n not in fact:
			fact[n] = factorial(n - 1) * n
		return fact[n]
	else:
		res = 1
		while n > 0:
			res = res * n % mod
			n -= 1
		return res

def sum_of(a):
	res = 0
	for x in a:
		res = (res + x) % mod
	return res

def prod_of(a):
	res = 1
	for x in a:
		res = res * x % mod
	return res

def test():
	n = get()[0]
	a = sorted(get())
	b = {}
	for x in a:
		if x in b:
			b[x] += 1
		else:
			b[x] = 1
	mx = max(a) + 1
	ans = 0
	for i in range(mx + 1):
		if i not in b or b[i] == 0:
			ans += i
			break
		else:
			b[i] -= 1
	for i in range(mx + 1):
		if i not in b or b[i] == 0:
			ans += i
			break
		else:
			b[i] -= 1
	print(ans)
main(cases)


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = defaultdict(int)
	for i in l:
		d[i] += 1
	c = 0
	sum = 0
	(l1, l2) = ([], [])
	for i in range(0, 1001):
		if d[i] >= 2 and c == 0:
			l1.append(i)
			l2.append(i)
		elif d[i] == 0:
			break
		else:
			c = 1
			l1.append(i)
	if len(l1) == 0:
		l1 = [-1]
	if len(l2) == 0:
		l2 = [-1]
	x = max(l1)
	y = max(l2)
	print(x + y + 2)


t = int(input())
for i in range(t):
	n = int(input())
	arr = map(int, input().split())
	freq = [0 for i in range(101)]
	for k in arr:
		freq[k] += 1
	ans = 0
	for j in range(0, 101):
		if freq[j] != 0:
			ans += 1
			freq[j] = freq[j] - 1
		else:
			break
	tf = 0
	for j in range(0, 101):
		if freq[j] != 0:
			ans += 1
			freq[j] = freq[j] - 1
		else:
			break
	print(ans)


import math
from collections import deque
from collections import defaultdict
t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	arr = list(map(int, input().strip().split(' ')))
	fq = [0] * 101
	for i in arr:
		fq[i] += 1
	ans = 0
	ct = 0
	for i in range(101):
		if fq[i] < 2:
			ans += i
			ct = i
			break
	for i in range(i, 101):
		if fq[i] < 1:
			ans += i
			ct = i
			break
	print(ans)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	a = 0
	k = max(l) + 2
	for i in range(k):
		if i not in l:
			a = i
			break
	if a != 0:
		for i in range(a):
			l.remove(i)
		if len(l) != 0:
			k = max(l) + 2
			b = 0
			for i in range(k):
				if i not in l:
					b = i
					break
			print(a + b)
		else:
			print(a)
	else:
		print(0)


from collections import *
for u in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = [0] * 101
	for i in l:
		d[i] += 1
	x = -1
	for i in range(101):
		if d[i] == 0:
			x = i
			break
	r = 0
	i = 0
	while i < 101 and d[i] > 1:
		i += 1
	if i < 101 and d[i] == 0:
		r = 2 * i
		print(max(x, r))
		continue
	r += i
	i += 1
	while i < 101 and d[i] > 0:
		i += 1
	r += i
	print(max(r, x))


from collections import Counter
T = int(input())
for i in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	C = Counter(A)
	flag1 = False
	for i in range(102):
		if not i in C:
			if flag1:
				b = i
			else:
				a = i
				b = i
			break
		elif C[i] == 1:
			if not flag1:
				a = i
				flag1 = True
	print(a + b)


t = int(input())
for _ in range(t):
	n = int(input())
	l1 = sorted([int(x) for x in input().split()])
	i = 0
	ans = 0
	while i < 2:
		j = 0
		while j in l1:
			l1.remove(j)
			j += 1
		ans += j
		i += 1
	print(ans)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
from decimal import Decimal
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(var, end='\n'):
	sys.stdout.write(str(var) + end)

def outa(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(int(data())):
	n = int(data())
	c = C(l())
	answer = 0
	for i in range(101):
		if not c[i]:
			answer = i
			break
		c[i] -= 1
	for i in range(101):
		if not c[i]:
			answer += i
			break
	out(answer)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	m = 0
	k = 0
	for i in range(max(l) + 2):
		d[i] = l.count(i)
	for i in range(max(l) + 2):
		if d[i] < 1:
			m = i
			break
		else:
			d[i] = d[i] - 1
	for i in range(max(l) + 2):
		if d[i] < 1:
			k = i
			break
		else:
			d[i] = d[i] - 1
	print(m + k)


def mex(hash_map):
	for i in range(0, 1000):
		if i not in hash_map:
			return i
	return None
t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = list(map(int, input().strip().split()))
	a.sort()
	used = {}
	used2 = {}
	for i in a:
		if i in used:
			used2[i] = 1
		else:
			used[i] = 1
	print(mex(used) + mex(used2))


import sys
import math

def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def MI():
	return map(int, sys.stdin.readline().split())

def SI():
	return sys.stdin.readline().strip()
t = II()
for q in range(t):
	n = II()
	a = LI()
	d = [0] * 101
	for i in range(n):
		d[a[i]] += 1
	ans = 0
	boo = False
	for i in range(101):
		if boo == False and d[i] < 2:
			ans += i
			boo = True
		if boo == True and d[i] < 1:
			ans += i
			break
	print(ans)


for _ in range(int(input())):
	input()
	a = [*map(int, input().split())]
	b = c = 0
	while a.count(c) > 1:
		b += 1
		c += 1
	while a.count(c):
		c += 1
	print(b + c)


t = int(input())
for q in range(t):
	n = int(input())
	ch = input()
	L = [int(i) for i in ch.split()]
	M = [0] * 102
	for i in range(n):
		M[L[i]] += 1
	for i in range(102):
		if M[i] == 0:
			x = i
			break
		M[i] -= 1
	for i in range(102):
		if M[i] == 0:
			y = i
			break
		M[i] -= 1
	print(x + y)


t = int(input())
for _ in range(t):
	_ = input()
	arr = [int(n) for n in input().split(' ')]
	counts = [0 for _ in range(101)]
	for x in arr:
		counts[x] += 1
	res = 0
	for _ in range(2):
		curr = 0
		while counts[curr] > 0:
			counts[curr] -= 1
			curr += 1
		res += curr
	print(res)


import collections

def solve():
	n = int(input())
	l = list(map(int, input().split()))
	c = collections.Counter(l)
	cur = 0
	cur2 = 0
	l.sort()
	s = set(l)
	for e in s:
		if e != cur:
			break
		else:
			cur += 1
	for e in s:
		if e == cur2 and c[e] > 1:
			cur2 += 1
		else:
			break
	return cur + cur2
for __ in range(int(input())):
	print(solve())


t = int(input())
for i in range(0, t):
	n = int(input())
	a = input().split()
	c = []
	for j in a:
		c.append(int(j))
	ans = 0
	a = c
	bl = False
	bl2 = False
	bl3 = False
	for k in range(0, len(a)):
		if a[k] != k:
			bl3 = True
	if bl3:
		for j in range(0, max(c) + 2):
			if a.count(j) == 0:
				bl2 = True
				if bl:
					ans = ans + j
					break
				else:
					ans = ans + 2 * j
					break
			elif a.count(j) == 1 and bl == False:
				ans = ans + j
				bl = True
		print(ans)
	else:
		print(max(c) + 1)


for _ in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()]
	a = set(l)
	b = set()
	for i in a:
		if l.count(i) > 1:
			b.add(i)
	ans = 0
	if min(a) != 0:
		ans += 0
	else:
		a = sorted(a)
		flag = True
		for i in range(len(a) - 1):
			if a[i + 1] - a[i] != 1:
				ans += a[i] + 1
				flag = False
				break
		if flag:
			ans += max(a) + 1
	if len(b) > 0 and min(b) != 0:
		ans += 0
	else:
		b = sorted(b)
		flag = True
		for i in range(len(b) - 1):
			if b[i + 1] - b[i] != 1:
				ans += b[i] + 1
				flag = False
				break
		if flag:
			if len(b) != 0:
				ans += max(b) + 1
	print(ans)


def solution(arr: list) -> int:
	freqArr = []
	mexA = 0
	mexB = 0
	r = list(range(max(arr) + 2))
	for i in r:
		freqArr.append(arr.count(i))
	for x in range(len(freqArr)):
		if freqArr[x] > 0:
			freqArr[x] -= 1
		else:
			mexA = r[x]
			break
	for y in range(len(freqArr)):
		if freqArr[y] > 0:
			freqArr[y] -= 1
		else:
			mexB = r[y]
			break
	return mexA + mexB
t = int(input())
for _ in range(t):
	n = int(input())
	i = input().split(' ')
	i = [int(x) for x in i]
	print(solution(i))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(mexA, mexB) = (0, 0)
	k = max(a)
	for i in range(k + 2):
		if i not in a:
			mexA = i
			break
		if i in a:
			del a[a.index(i)]
	for j in range(k + 2):
		if j not in a:
			mexB = j
			break
		if j in a:
			del a[a.index(j)]
	print(mexA + mexB)


import sys
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = sorted(list(map(int, input().split())))
	l = []
	ate = list(set(a))
	for i in range(len(ate)):
		co = a.count(ate[i])
		l.append([ate[i], co])
	x = []
	y = []
	ax = 0
	ay = 0
	ans = 0
	for i in range(len(l)):
		no = l[i][0]
		fre = l[i][1]
		if fre >= 2:
			x.append(no)
			y.append(no)
		elif fre == 1:
			x.append(no)
	if len(x) >= 1:
		x1 = 0
		for i in range(len(x)):
			if x[i] != i:
				x1 = 1
				ax = i
				break
		if not x1:
			ans += x[len(x) - 1] + 1
		else:
			ans += ax
	if len(y) >= 1:
		y1 = 0
		for i in range(len(y)):
			if y[i] != i:
				y1 = 1
				ay += i
				break
		if not y1:
			ans += y[len(y) - 1] + 1
		else:
			ans += ay
	print(ans)


for _ in range(int(input())):
	input()
	a = list(map(int, input().split()))
	a.sort()
	m1 = 0
	m2 = 0
	pairs = True
	while len(a) > 0:
		if a[0] == m1:
			m1 += 1
			a.pop(0)
		elif a[0] == m2:
			m2 += 1
			a.pop(0)
		elif a[0] < m1 or a[0] < m2:
			a.pop(0)
			continue
		else:
			break
	print(m1 + m2)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	z = max(a) + 1
	for j in range(n):
		s = a.count(j)
		if s == 0:
			z = j
			break
	for j in range(n):
		s = a.count(j)
		if s == 1 or s == 0:
			z = z + j
			break
	print(z)


import sys
import heapq, functools, collections
import math, random
from collections import Counter, defaultdict

def solve(lst):
	console('----- solving ------')
	c = Counter(lst)
	cur = 0
	while True:
		if c[cur] < 2:
			a = cur
			break
		cur += 1
	while True:
		if c[cur] < 1:
			b = cur
			break
		cur += 1
	return a + b

def console(*args):
	print('\x1b[36m', *args, '\x1b[0m', file=sys.stderr)
	return
for case_num in range(int(input())):
	k = int(input())
	lst = list(map(int, input().split()))
	res = solve(lst)
	print(res)


def Solve():
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ptr = 0
	MAX = 111
	cnt = [0] * MAX
	while ptr < n:
		nptr = ptr + 1
		while nptr < n and a[nptr] == a[ptr]:
			nptr += 1
		cnt[a[ptr]] += nptr - ptr
		ptr = nptr
	for mex in range(MAX):
		if cnt[mex] == 0:
			print(mex + mex)
			return
		if cnt[mex] == 1:
			for other in range(mex + 1, MAX):
				if cnt[other] == 0:
					print(mex + other)
					return
for _ in range(int(input())):
	Solve()


t = int(input())
while t:
	h = int(input())
	c = list(map(int, input().split()))
	a = []
	b = []
	c = sorted(c)
	for x in c:
		if x in a:
			b.append(x)
		else:
			a.append(x)
	s = 0
	i = 0
	if len(a):
		while 1:
			if i not in a:
				s += i
				break
			i += 1
	i = 0
	if len(b):
		while 1:
			if i not in b:
				s += i
				break
			i += 1
	print(s)
	t -= 1


t = int(input())
ans = []
for i in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = []
	if 0 not in a:
		ans.append(0)
	else:
		i = 0
		while True:
			if i in a:
				b.append(i)
				a.remove(i)
				i += 1
			else:
				break
		count = max(b) + 1
		b = []
		i = 0
		while True:
			if i in a:
				b.append(i)
				a.remove(i)
				i += 1
			else:
				break
		count += i
		ans.append(count)
for i in ans:
	print(i)


for _ in range(int(input())):
	n = int(input())
	a = sorted([int(s) for s in input().split()])
	ansa = 0
	ansb = 0
	i = 0
	while i in a:
		a.remove(i)
		ansa += 1
		i += 1
	i = 0
	while i in a:
		a.remove(i)
		ansb += 1
		i += 1
	print(ansa + ansb)


for t in range(int(input())):
	n = int(input())
	set1_list_form = list(map(int, input().split()))
	l1 = [0 for i in range(0, 101)]
	set1 = set(set1_list_form)
	for i in set1:
		l1[i] = set1_list_form.count(i)
	a = 0
	for i in range(0, 101):
		if l1[i] == 0:
			a += i
			break
	for i in range(0, 101):
		if l1[i] <= 1:
			a += i
			break
	print(a)


tests = int(input())
for testnum in range(tests):
	n = int(input())
	counter = [0] * 101
	ret = -1
	numbers = map(int, input().split())
	numbers = list(numbers)
	for i in range(n):
		counter[numbers[i]] += 1
	ones = -1
	for i in range(101):
		if counter[i] == 0:
			ones = i
			break
	twos = -1
	for i in range(101):
		if counter[i] < 2:
			twos = i
			break
	if ones < 0:
		ones = 100
		if twos < 0:
			ret = 200
		else:
			ret = ones + twos
	elif twos < 0:
		ret = 100 + ones
	else:
		ret = ones + twos
	print(ret)


t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	count = [0] * 101
	for a in A:
		count[a] += 1
	(a1, a2) = (-1, -1)
	flag = False
	for i in range(len(count)):
		if not flag:
			if count[i] > 1:
				continue
			elif count[i] == 1:
				flag = True
				a1 = i
			else:
				(a1, a2) = (i, i)
				break
		elif count[i] > 0:
			continue
		else:
			a2 = i
			break
	if a1 == -1:
		a1 = 101
	if a2 == -1:
		a2 = 101
	print(a1 + a2)


import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
import threading
from collections import defaultdict
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n

class SegmentTree1:

	def __init__(self, data, default=0, func=lambda a, b: max(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] < key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] >= k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater
for ik in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = defaultdict(int)
	for i in range(n):
		d[l[i]] += 1
	ans = 0
	t = 0
	for i in range(max(l) + 2):
		if d[i] == 0:
			ans += i + i
			t = 1
			break
		if d[i] == 1:
			ans += i
			break
	if t == 1:
		print(ans)
		continue
	for i in range(max(l) + 2):
		if d[i] == 0:
			ans += i
			break
	print(ans)


TC = int(input())
for tc in range(TC):
	N = int(input())
	A = list(map(int, input().split()))
	cnt = [0 for _ in range(101)]
	for a in A:
		cnt[a] += 1
	m1 = -1
	m2 = -1
	for (i, c) in enumerate(cnt):
		if m1 == -1:
			if c < 2:
				m1 = i
		if c == 0:
			m2 = i
			break
	print(m1 + m2)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	c = Counter(a)
	ans = 0
	check = 0
	for i in range(101):
		if i not in c:
			if check == 1:
				ans += i
				break
			else:
				ans = 2 * i
				break
		elif c[i] == 1:
			if check == 0:
				check += 1
				ans += i
	print(ans)


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	l1 = []
	l2 = []
	ans = 0
	h = defaultdict(int)
	for i in a:
		h[i] += 1
	for i in h:
		if h[i] >= 2:
			l1.append(i)
			h[i] -= 1
			for j in range(h[i]):
				l2.append(i)
			for j in range(h[i] + 1):
				a.remove(i)
			h[i] = -1
	for i in range(0, 102):
		if i in l1:
			continue
		if i in a:
			l1.append(i)
			a.remove(i)
		else:
			ans += i
			break
	for i in range(0, 102):
		if i in l2:
			continue
		if i in a:
			l2.append(i)
			a.remove(i)
		else:
			ans += i
			break
	print(ans)


import sys, os.path
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
sys.setrecursionlimit(10 ** 5)

def i():
	return sys.stdin.readline().strip()

def ii():
	return int(sys.stdin.readline())

def li():
	return list(sys.stdin.readline().strip())

def mii():
	return map(int, sys.stdin.readline().split())

def lii():
	return list(map(int, sys.stdin.readline().strip().split()))

def solve():
	a = ii()
	b = lii()
	c = []
	d = e = 0
	[c.append(x) and b.remove(x) for x in b if b.count(x) > 1 and x not in c]
	[b.remove(x) for x in c]
	for i in range(max(b) + 2):
		if i not in b:
			d = i
			break
	if len(c) != 0:
		for i in range(max(c) + 2):
			if i not in c:
				e = i
				break
	print(d + e)
for _ in range(ii()):
	solve()


MOD = 1000000007
from collections import defaultdict as dd, Counter, deque

def si():
	return input()

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))

def mi():
	return map(int, input().split())

def out(v):
	print(v)

def spout():
	print(v, end=' ')

def d2b(n):
	return bin(n).replace('0b', '')

def twod(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def vow():
	return ['a', 'e', 'i', 'o', 'u']

def let():
	return [chr(i) for i in range(97, 123)]

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def ispow2(x):
	return x and (not x & x - 1)

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)
t = ii()
while t:
	t -= 1
	n = ii()
	a = li()
	d = {}
	for i in range(101):
		d[i] = 0
	for i in a:
		d[i] += 1
	s = 0
	for (i, j) in d.items():
		if j == 0:
			s += i
			break
		else:
			d[i] -= 1
	for (i, j) in d.items():
		if j == 0:
			s += i
			break
	print(s)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	x = -1
	y = -1
	for j in range(n):
		if l[j] == x + 1:
			x += 1
		elif l[j] == y + 1:
			y += 1
		elif l[j] == x or l[j] == y:
			pass
		else:
			break
	print(x + y + 2)


tc = int(input())
for t in range(tc):
	n = int(input())
	arr = list(map(int, input().strip().split()))[:n]
	arr = sorted(arr)
	setA = []
	setB = []
	for num in arr:
		if not setA:
			setA.append(num)
		elif num in setA:
			setB.append(num)
		else:
			setA.append(num)
	mexA = mexB = 0
	if not setA:
		mexA = 0
	else:
		for x in range(0, max(setA) + 2):
			if x not in setA:
				mexA = x
				break
	if not setB:
		mexB = 0
	else:
		for x in range(0, max(setB) + 2):
			if x not in setB:
				mexB = x
				break
	print(mexA + mexB)


import math
t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	rem = 2
	result = 0
	count = [0] * 101
	for num in a:
		count[num] += 1
	for i in range(0, 101):
		if count[i] < rem:
			temp = rem - count[i]
			result += temp * i
			rem -= temp
	print(result)
	t -= 1


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	l = list(map(int, input().split()))
	lst = [0] * 101
	for i in l:
		lst[i] += 1
	for i in range(len(lst)):
		if lst[i] == 0:
			mexA = i
			break
	for i in range(len(lst)):
		if lst[i] <= 1:
			mexB = i
			break
	print(mexA + mexB)


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = defaultdict(int)
	for i in a:
		d[i] += 1
	s = 0
	for j in range(2):
		for i in range(101):
			if d[i] > 0:
				d[i] -= 1
			else:
				s += i
				break
	print(s)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	j = 0
	while len(a) >= 2 and a[0] == a[1] and (a[0] == j):
		a = a[2:]
		i = 0
		for x in a:
			if x == j:
				i += 1
			else:
				break
		a = a[i:]
		j += 1
	if len(a) == 0 or a[0] != j:
		print(2 * j)
	else:
		b = list(set(a[1:]))
		b.sort()
		cur = 0
		i = j + 1
		for x in b:
			if x != i:
				break
			i += 1
		print(j + i)


for _ in range(int(input())):
	n = int(input())
	x = [int(i) for i in input().split()]
	d = {}
	for i in x:
		d[i] = d.get(i, 0) + 1
	(a, b) = (0, 0)
	while d.get(a, 0) != 0:
		if d.get(a, 0) >= 2 and a == b:
			b += 1
		a += 1
	print(a + b)


import math, sys
from collections import defaultdict, Counter, deque
from functools import reduce
INF = float('inf')
MOD = int(1000000000.0) + 7

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def isPrime(n):
	if n <= 1:
		return False
	i = 2
	while i ** 2 <= n:
		if n % i == 0:
			return False
		i += 1
	return True

def primeFactors(n):
	factors = defaultdict(int)
	i = 2
	while i ** 2 <= n:
		while n % i == 0:
			factors[i] += 1
			n //= i
		i += 1
	if n > 1:
		factors[n] += 1
	return factors

def a():
	n = int(input())
	arr = array()
	m = Counter(arr)
	mex1 = -1
	mex2 = -1
	for k in sorted(m.keys()):
		if mex1 + 1 != k:
			break
		mex1 += 1
		if mex2 + 1 == k and m[k] >= 2:
			mex2 += 1
	print(mex1 + mex2 + 2)

def b():
	n = int(input())
	arr = array()
	arr.sort()
	ans = -INF
	for i in range(6):
		mul = 1
		l = i
		r = n - (5 - i)
		for i in range(0, l):
			mul *= arr[i]
		for i in range(r, n):
			mul *= arr[i]
		ans = max(ans, mul)
	print(ans)

class DSU:

	def __init__(self, n):
		self.p = [i for i in range(n + 1)]
		self.size = [1 for i in range(n + 1)]
		self.minmax = [[i, i] for i in range(n + 1)]
		self.n = n

	def find(self, node):
		if self.p[node] != node:
			self.p[node] = self.find(self.p[node])
		return self.p[node]

	def union(self, source, dest):
		source = self.find(source)
		dest = self.find(dest)
		if source != dest:
			if self.size[source] < self.size[dest]:
				(source, dest) = (dest, source)
			self.p[dest] = source
			self.size[source] += self.size[dest]
			mini = min(self.minmax[source][0], self.minmax[dest][0])
			maxi = max(self.minmax[source][1], self.minmax[dest][1])
			self.minmax[source] = [mini, maxi]

def input():
	return sys.stdin.readline().rstrip('\n')

def print(*args, sep=' ', end='\n'):
	first = True
	for arg in args:
		if not first:
			sys.stdout.write(sep)
		sys.stdout.write(str(arg))
		first = False
	sys.stdout.write(end)

def vars():
	return map(int, input().split())

def array():
	return list(map(int, input().split()))
t = 1
t = int(input())
for _ in range(t):
	a()


import os
import sys
from io import BytesIO, IOBase
import math

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(int(n))
	return l

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)
for xyz in range(0, int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	f = [0] * 102
	for i in l:
		f[i] += 1
		f[i] = min(2, f[i])
	a = 0
	c = 0
	i = 0
	for i in range(0, 102):
		if f[i] != 1:
			break
	a1 = i
	for i in range(0, 102):
		if f[i] != 2:
			break
	a2 = i
	for i in range(a2, 102):
		if f[i] == 0:
			break
	a2 += i
	print(max(a1, a2))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list()
	c = list()
	result = 0
	for i in range(n):
		if 1 <= a.count(i):
			b.append(i)
		else:
			break
	for i in range(n):
		if 2 <= a.count(i):
			c.append(i)
		else:
			break
	if len(b) == len(c):
		print(len(b) * 2)
	else:
		print(len(c) + len(b))


import math, sys, bisect, heapq
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
int1 = lambda x: int(x) - 1
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))
ilelec = lambda : map(int1, input().split())
alelec = lambda : list(map(int1, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])

def mex(A):
	for i in range(102):
		if i not in A:
			return i
for _ in range(int(input())):
	N = int(input())
	A = alele()
	x = A.count(0)
	if x == 0:
		print(0)
	elif x == 1:
		print(mex(A))
	else:
		A.sort()
		B = []
		C = []
		for i in A:
			if i not in B:
				B.append(i)
			else:
				C.append(i)
		print(mex(B) + mex(C))


def check(a):
	a = set(a)
	for i in range(101):
		if i not in a:
			return i
	else:
		return 101
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	m = check(l)
	x = 0
	while x < m:
		l.remove(x)
		x += 1
	m1 = check(l)
	print(m + m1)


def mex(a):
	for i in range(0, len(a) + 1):
		if i not in a:
			break
	return i
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	x = a.count(0)
	if x == 0:
		print(0)
	elif x == 1:
		print(mex(a))
	else:
		s1 = [0]
		s2 = [0]
		a.remove(0)
		a.remove(0)
		for i in range(len(a)):
			if a[i] not in s1:
				s1.append(a[i])
			else:
				s2.append(a[i])
		x1 = mex(s1)
		x2 = mex(s2)
		print(x1 + x2)


def mex(arr):
	for i in range(len(arr)):
		if i != arr[i]:
			return i
	return len(arr)
for i in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	a1 = []
	a2 = []
	for i in range(n):
		if lst[i] not in a1:
			a1.append(lst[i])
		else:
			a2.append(lst[i])
	f1 = mex(list(set(a1)))
	f2 = mex(list(set(a2)))
	f3 = mex(list(set(lst)))
	print(max(f1 + f2, f3))


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().strip().split(' ')))
	x = [0 for _ in range(101)]
	for i in a:
		x[i] += 1
	f1 = 0
	f2 = 0
	ans = 0
	for i in range(101):
		if f1 == 0 and f2 == 0 and (x[i] == 1):
			f1 = 1
			ans += i
		elif f1 == 0 and f2 == 0 and (x[i] == 0):
			f1 = 1
			f2 = 1
			ans += 2 * i
			break
		elif f2 == 0 and x[i] == 0:
			ans += i
			break
	print(ans)


import sys, os.path
import math
from collections import Counter
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def solve():
	n = int(input())
	l = list(map(int, input().split()))
	c = Counter(l)
	mex1 = 0
	mex2 = 0
	for i in range(101):
		if c[i] >= 2:
			mex1 = i + 1
			mex2 = i + 1
		else:
			break
	while i < 101:
		if c[i]:
			mex1 = i + 1
		else:
			break
		i += 1
	return mex1 + mex2
for _ in range(int(input())):
	print(solve())


for _ in range(int(input())):
	a = [0] * 105
	input()
	for i in map(int, input().split()):
		a[i] += 1
	ans = 0
	for i in range(101):
		if a[i] < 2:
			ans += i
			break
	for i in range(101):
		if a[i] < 1:
			ans += i
			break
	print(ans)


T = int(input())
for _ in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	dic = {}
	mex = max(A)
	for i in A:
		if i in dic:
			dic[i] += 1
		else:
			dic[i] = 1
	count = ans = 0
	flag = 1
	for i in range(mex + 2):
		if i in dic:
			if dic[i] == 1 and flag == 1:
				ans += i
				flag = 0
				count += 1
				if count == 2:
					break
		else:
			ans += i
			flag = 0
			count += 1
			break
	if count == 1:
		ans *= 2
	print(ans)


t = int(input())
for i in range(t):
	(a, b) = (0, 0)
	n = int(input())
	S = list(map(int, input().split()))
	i = 0
	v = True
	while i in S:
		S.remove(i)
		a = i + 1
		if i in S and v:
			b = i + 1
		else:
			v = False
		i = i + 1
	print(a + b)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	mex = []
	num = 0
	while len(mex) <= 1:
		c = a.count(num)
		if len(mex) == 0:
			if c == 0:
				mex.append(num)
				mex.append(num)
			elif c == 1:
				mex.append(num)
		elif len(mex) == 1:
			if c == 0:
				mex.append(num)
		num += 1
	ans = sum(mex)
	print(ans)


n = int(input())
for i in range(n):
	l = int(input())
	m = list(map(int, input().split()))
	a = []
	b = []
	for i in m:
		if i in a:
			b.append(i)
		else:
			a.append(i)
	s = set(range(101))
	b = set(b)
	a = set(a)
	mex = min(s - a) + min(s - b)
	print(mex)


from collections import Counter as C
import sys
pin = sys.stdin.readline
for T in range(int(pin())):
	N = int(pin())
	A = sorted(C([*map(int, pin().split())]).items())
	(f, sm, i) = (2, 0, 0)
	for (k, v) in A:
		if k == i and v >= f:
			i += 1
			continue
		elif k == i:
			sm += i
			i += 1
			f -= 1
		else:
			break
	sm += i * f
	print(sm)


def fun(ls, n):
	count = [0 for i in range(101)]
	for i in ls:
		count[i] += 1
	first_nonrepating = None
	first_absent = None
	for (i, val) in enumerate(count):
		if val <= 1 and first_nonrepating == None:
			first_nonrepating = i
		if val == 0 and first_absent == None:
			first_absent = i
	print(first_absent + first_nonrepating)
T = int(input())
for i in range(T):
	val = int(input())
	st = list(map(int, input().split()))
	fun(st, val)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	mexA = 0
	mexB = 0
	s = [0] * 101
	for i in range(n):
		s[l[i]] += 1
	for i in range(101):
		if s[i] == 0:
			mexA = i
			mexB = i
			break
		if s[i] == 1:
			mexB = i
			for k in range(101):
				if s[k] == 0:
					mexA = k
					break
			break
	print(mexA + mexB)


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = set(a)
	x = -1
	for i in range(n):
		if a.count(i) == 0:
			x = i
			break
	if x == -1:
		x = n
	y = -1
	for i in range(x):
		if a.count(i) == 1:
			y = i
			break
	if y == -1:
		y = x
	print(x + y)


import sys
import os
from io import BytesIO, IOBase

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def ddi():
	return defaultdict(int)

def ddl():
	return defaultdict(list)

def ddd():
	return defaultdict(defaultdict(int))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import defaultdict
from math import gcd, pi, inf
from collections import Counter
for _ in range(ii()):
	n = ii()
	a = li()
	cnt = Counter(a)
	(mexa, mexb) = (-1, -1)
	for i in range(110):
		if cnt[i] == 0:
			mexa = i
			break
	for i in range(110):
		if cnt[i] <= 1:
			mexb = i
			break
	print(mexa + mexb)


from collections import deque
from math import *
t = int(input())
for _ in range(t):
	n = int(input())
	arr = sorted([int(p) for p in input().split()])
	count = {}
	for i in range(len(arr)):
		try:
			count[arr[i]] += 1
		except KeyError:
			count[arr[i]] = 1
	a1 = []
	a2 = []
	for i in count:
		a1.append(i)
		count[i] -= 1
	for i in count:
		if count[i] > 0:
			a2.append(i)
	c1 = 0
	c2 = 0
	for i in range(len(a1)):
		if a1[i] != i:
			c1 = i
			break
		if i == len(a1) - 1:
			c1 = i + 1
	for i in range(len(a2)):
		if a2[i] != i:
			c2 = i
			break
		if i == len(a2) - 1:
			c2 = i + 1
	print(c1 + c2)


def solve(l):
	d = dict()
	s = set(l)
	s = list(s)
	s.sort()
	for i in range(0, len(s)):
		if i != s[i]:
			mex_a = i
			break
		elif i == len(s) - 1:
			mex_a = i + 1
	for i in l:
		if i in d:
			d[i] = d[i] + 1
		else:
			d[i] = 1
	for i in range(0, 101):
		if i not in d.keys():
			d[i] = 0
	for i in range(0, 101):
		if d[i] < 2:
			mex_b = i
			break
	print('{}'.format(mex_a + mex_b))

def main():
	for i in range(int(input())):
		n = input()
		solve([int(x) for x in input().split()])
main()


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	d = dict()
	for i in range(n):
		if arr[i] in d:
			d[arr[i]] += 1
		else:
			d[arr[i]] = 1
	mexa = 0
	mexb = 0
	flag = True
	for i in range(max(arr) + 1):
		if i in d:
			if d[i] > 1:
				mexa = i + 1
				if flag:
					mexb = i + 1
			else:
				mexa = i + 1
				flag = False
		else:
			break
	print(mexa + mexb)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l2 = [0] * 120
	for num in l:
		l2[num] += 1
	ans1 = 0
	ans2 = 0
	for i in range(0, 105):
		if l2[i] == 0:
			ans1 = i
			break
		else:
			l2[i] -= 1
	for i in range(0, 105):
		if l2[i] == 0:
			ans2 = i
			break
		else:
			l2[i] -= 1
	print(ans1 + ans2)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass
for _ in range(L()[0]):
	n = L()[0]
	A = L()
	cnt = [0 for i in range(101)]
	for ele in A:
		cnt[ele] += 1
	a = -1
	b = -1
	for i in range(101):
		if cnt[i] == 0:
			b = i
			if a == -1:
				a = i
			break
		if cnt[i] <= 1 and a == -1:
			a = i
	print(a + b)
endtime = time.time()


t = int(input())
for _ in range(t):
	n = int(input())
	li = list(map(int, input().split()))
	i = 0
	res = 0
	cnt = 0
	while cnt != 2:
		if li.count(i) == 0:
			if cnt == 0:
				res += 2 * i
			else:
				res += i
			cnt = 2
		if li.count(i) >= 2 - cnt:
			i += 1
			continue
		else:
			cnt += 1
			res += i
	print(res)


import sys
import math, bisect
sys.setrecursionlimit(10 ** 5)
from collections import defaultdict
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, OrderedDict

def I():
	return int(sys.stdin.readline())

def neo():
	return map(int, sys.stdin.readline().split())

def Neo():
	return list(map(int, sys.stdin.readline().split()))
for _ in range(I()):
	N = I()
	A = Neo()
	(Ans, f) = (0, 0)
	for i in range(101):
		if A.count(i) == 1 and f == 0:
			Ans = i
			f = 1
		elif A.count(i) == 0:
			if f == 1:
				Ans += i
			else:
				Ans += 2 * i
			break
	print(Ans)


def subsetMex(arr):
	hashSet = {}
	for i in arr:
		if i in hashSet:
			hashSet[i] += 1
		else:
			hashSet[i] = 1
	mex = None
	for i in range(102):
		if i not in hashSet:
			mex = i
			break
	for i in range(mex):
		if hashSet[i] < 2:
			return mex + i
	return 2 * mex
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	print(subsetMex(arr))


MAXN = 100

def constructMEX(arr, N):
	for i in range(100):
		if i not in arr:
			return i
	return 100
t = int(input())
while t:
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	freq = {}
	for i in arr:
		if i in freq:
			freq[i] += 1
		else:
			freq[i] = 1
	if constructMEX(arr, n) == 0:
		print(0)
	elif arr.count(0) <= 1:
		print(constructMEX(arr, n))
	else:
		B = []
		for i in set(arr):
			if freq[i] > 1:
				B.append(i)
		B.sort()
		print(constructMEX(arr, n) + constructMEX(B, len(B)))
	t -= 1


Q = int(input())
for i in range(Q):
	N = int(input())
	L = list(map(int, input().split()))
	A = [0 for i in range(100 + 2)]
	B = [0 for i in range(100 + 2)]
	for n in range(N):
		if A[L[n]] == 0:
			A[L[n]] = 1
		else:
			B[L[n]] = 1
	a = 0
	b = 0
	for i in range(len(A)):
		if A[101 - i] == 0:
			a = 101 - i
		if B[101 - i] == 0:
			b = 101 - i
	print(a + b)


import sys, math
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	(s, d) = (0, 0)
	mas = []
	for i in range(n):
		if a[i] == s:
			s += 1
			mas.append(i)
		elif a[i] > s:
			break
	n -= len(mas)
	l = 0
	ans = s
	s = 0
	for i in mas:
		del a[i - l]
		l += 1
	for i in range(n):
		if a[i] == s:
			s += 1
			mas.append(i)
		elif a[i] > s:
			break
	ans += s
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	dic = [0] * 101
	for i in a:
		dic[i] += 1
	ans = 0
	i = 0
	while dic[i] != 0:
		count = dic[i]
		dic[i] -= 1
		i += 1
	ans = i
	i = 0
	while dic[i] != 0:
		count = dic[i]
		dic[i] -= 1
		i += 1
	ans += i
	print(ans)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	(s, e) = (0, 0)
	for i in arr:
		if i == s:
			s += 1
		elif i == e:
			e += 1
	print(s + e)


def mex(list1):
	if len(list1) == 0:
		return 0
	else:
		max1 = max(list1)
		for i in range(max1 + 1):
			if i not in list1:
				return i
		return max1 + 1
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	sum = 0
	first = []
	second = []
	for i in range(n):
		x = a.count(i)
		if x == 2 or x > 2:
			first.append(i)
			second.append(i)
		elif x == 1:
			first.append(i)
	sum = mex(first) + mex(second)
	print(sum)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = I()
	rr = []
	for _ in range(t):
		n = I()
		a = LI()
		c = collections.Counter(a)
		d = e = 0
		for i in range(n + 1):
			if c[i] < 2:
				d = i
				break
		for i in range(n + 1):
			if c[i] < 1:
				e = i
				break
		rr.append(d + e)
	return JA(rr, '\n')
print(main())


t = int(input())
for i in range(t):
	n = int(input())
	l = [int(x) for x in input().split()]
	d = {}
	a = []
	b = []
	for x in l:
		if x in d:
			b.append(x)
		else:
			a.append(x)
			d[x] = True
	a.sort()
	b.sort()
	i = 0
	c1 = 0
	while c1 in a:
		c1 += 1
	c2 = 0
	while c2 in b:
		c2 += 1
	print(c1 + c2)


t = int(input())
while t != 0:
	n = int(input())
	s = input()
	arr = s.split()
	arr = [int(ele) for ele in arr]
	arr.sort()
	hm = {}
	for num in arr:
		if num not in hm:
			hm[num] = 0
		hm[num] += 1
	c_l1 = -1
	c_l2 = -1
	fix_l2 = 0
	for i in range(len(arr)):
		if fix_l2 != 1:
			if i in hm and hm[i] >= 2:
				c_l1 = i
				c_l2 = i
			elif i in hm and hm[i] == 1:
				c_l1 = i
				fix_l2 = 1
			else:
				break
		elif i in hm and hm[i] > 0:
			c_l1 = i
		else:
			break
	print(c_l1 + c_l2 + 2)
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	li = list(map(int, input().split()))
	s_for = 2
	first = second = -1
	arr = [0] * 102
	for i in range(n):
		arr[li[i]] += 1
	for i in range(102):
		if arr[i] == 1:
			if first == -1:
				first = i
				s_for -= 1
		if arr[i] == 0:
			if first == -1 and second == -1:
				first = second = i
				s_for -= 2
			else:
				second = i
				s_for -= 1
		if s_for == 0:
			break
	print(first + second)


for j in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	init = 0
	is_first = False
	for i in range(0, 101):
		if not is_first and l.count(i) == 0:
			print(i + i)
			break
		elif not is_first and l.count(i) < 2:
			init = i
			is_first = True
			continue
		elif is_first and l.count(i) == 0:
			print(i + init)
			break


import sys
ii = lambda : sys.stdin.readline().strip()
idata = lambda : [int(x) for x in ii().split()]

def solve():
	n = int(ii())
	data = sorted(idata())
	a = -1
	b = -1
	for i in range(n):
		if data[i] == a + 1:
			a += 1
		elif data[i] == a:
			if b + 1 == data[i]:
				b += 1
	print(a + b + 2)
	return
for t in range(int(ii())):
	solve()


from fractions import Fraction
import bisect
import os
import io
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate
from queue import Queue

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
t = 1
t = iinput()
for _ in range(t):
	n = iinput()
	a = rlinput()
	count = Counter(a)
	ans = 0
	got = 0
	for i in range(max(a) + 1):
		if count[i] == 0:
			if got == 0:
				ans += 2 * i
				got = 2
				break
			elif got == 1:
				ans += i
				got += 1
		elif count[i] == 1:
			if got == 0:
				ans += i
				got += 1
		if got >= 2:
			break
	if got == 1:
		ans += max(a) + 1
	if got == 0:
		ans += 2 * (max(a) + 1)
	print(ans)


from collections import defaultdict, Counter
for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	d = defaultdict(int)
	d = Counter(l)
	l1 = set()
	l2 = set()
	for i in l:
		if d[i] > 1:
			l1.add(i)
			l2.add(i)
		else:
			l1.add(i)
	j = 0
	s = 0
	l1 = list(l1)
	l2 = list(l2)
	l1.sort()
	l2.sort()
	c1 = 0
	for i in l1:
		if i == j:
			j += 1
		else:
			s += j
			c1 = 1
			break
	if c1 == 0:
		s += j
	j = 0
	c1 = 0
	for i in l2:
		if i == j:
			j += 1
		else:
			s += j
			c1 = 1
			break
	if c1 == 0:
		s += j
	print(s)


t = int(input())
for _ in range(t):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(set(l1))
	l3 = []
	l2.sort()
	(x, y) = (min(l2), max(l2))
	ans = 0
	if x == 0:
		(f, c) = (0, 0)
		for i in range(x, y + 1):
			if i not in l2:
				c = i
				f = 1
				break
		if f == 0:
			ans += y + 1
		else:
			ans += c
	if len(l1) != len(l2):
		for i in l2:
			if l1.count(i) > 1:
				l3.append(i)
		(x, y) = (min(l3), max(l3))
		if x == 0:
			(f, c) = (0, 0)
			for i in range(x, y + 1):
				if i not in l3:
					c = i
					f = 1
					break
			if f == 0:
				ans += y + 1
			else:
				ans += c
	print(ans)


T = int(input())
while T:
	n = int(input())
	A = list(map(int, input().split()))
	D = {}
	for i in range(max(A) + 1):
		D[i] = 0
	for i in A:
		D[i] += 1
	a = max(A) + 1
	for i in range(max(A) + 1):
		if D[i] == 0:
			a = i
			break
		else:
			D[i] -= 1
	b = max(A) + 1
	for i in range(max(A) + 1):
		if D[i] == 0:
			b = i
			break
		else:
			D[i] -= 1
	print(a + b)
	T = T - 1


res = []
for x in range(int(input())):
	a = int(input())
	l = list(map(int, input().split()))
	m = set(l)
	ans1 = []
	ans2 = []
	fi = []
	sec = []
	for y in m:
		e = l.count(y)
		if e > 1:
			sec.append(y)
			fi.append(y)
		else:
			fi.append(y)
	for t in range(len(sec) + 1):
		if t not in sec:
			ans1.append(t)
			break
		if t == len(sec):
			ans1.append(t)
			break
	if len(sec) == 0:
		d = 0
		ans1.append(d)
	for t in range(len(fi) + 1):
		if t not in fi:
			ans2.append(t)
			break
		if t == len(fi):
			ans1.append(t)
			break
	if len(fi) == 0:
		d = 0
		ans2.append(d)
	final = sum(ans1) + sum(ans2)
	res.append(final)
for B in res:
	print(B)


k = int(input())
for i in range(0, k):
	o = int(input())
	a = list(map(int, input().split()))
	a.sort()
	b = []
	c = 0
	for i in a:
		if i not in b:
			b.append(i)
	for j in b:
		if j in a:
			a.remove(j)
	if len(b) > 0:
		for u in range(0, max(b) + 2):
			if u not in b:
				c += int(u)
				break
	if len(a) > 0:
		for y in range(0, max(a) + 2):
			if y not in a:
				c += int(y)
				break
	print(c)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	occurrences = [0] * (n + 1)
	for a_i in a:
		if a_i < n:
			occurrences[a_i] += 1
	occurrences.append(1)
	mex_a = occurrences.index(0)
	mex_b = min(occurrences.index(0), occurrences.index(1))
	print(mex_a + mex_b)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().rstrip().rsplit()))
	(new, a, b) = ([], 0, 0)
	arr.sort()
	f = [arr.count(i) for i in range(arr[n - 1] + 2)]
	for i in range(arr[n - 1] + 2):
		if f[i] > 0:
			f[i] -= 1
		else:
			a = i
			break
	for i in range(n):
		if f[i] > 0:
			f[i] -= 1
		else:
			b = i
			break
	print(b + a)


import time, math as mt, bisect as bs, sys
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
pi = 3.141592653589793

def II():
	return int(stdin.readline())

def IP():
	return map(int, stdin.readline().split())

def L():
	return list(map(int, stdin.readline().split()))

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

def lcm(a, b):
	return a * b // gcd(a, b)

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def sieve():
	li = [True] * (2 * 10 ** 5 + 5)
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	prime = []
	for i in range(2 * 10 ** 5 + 5):
		if li[i] == True:
			prime.append(i)
	return prime

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count
mx = 10 ** 7
spf = [mx] * (mx + 1)

def SPF():
	spf[1] = 1
	for i in range(2, mx + 1):
		if spf[i] == mx:
			spf[i] = i
			for j in range(i * i, mx + 1, i):
				if i < spf[j]:
					spf[j] = i
	return

def readTree(n, e):
	adj = [set() for i in range(n + 1)]
	for i in range(e):
		(u1, u2) = IP()
		adj[u1].add(u2)
	return adj
mod = 10 ** 9 + 7

def mex(li):
	for i in range(101):
		if i not in li:
			return i

def solve():
	n = II()
	li = L()
	(l1, l2) = ([], [])
	for ele in li:
		l1.append(ele)
		if li.count(ele) > 1:
			l2.append(ele)
	print(mex(l1) + mex(l2))
t = II()
for i in range(t):
	solve()


import sys, os, io
input = sys.stdin.readline
T = int(input())
ans = [0] * T
for t in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	cnt = 0
	for i in range(101):
		c = A.count(i)
		if c == 0:
			ans[t] += i * (2 - cnt)
			cnt = 2
		elif c == 1:
			if cnt == 0:
				ans[t] += i
				cnt = 1
		if cnt == 2:
			break
print(*ans, sep='\n')


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	count = dict()
	count = defaultdict(lambda : 0, count)
	for i in range(n):
		count[a[i]] += 1
	p = 0
	while count[p] != 0:
		p += 1
	i = 0
	while count[i] > 1:
		i += 1
	p += i
	print(p)


T = int(input())
for _ in range(T):
	N = int(input())
	A = [int(a) for a in input().split()]
	X = [0] * 200
	for a in A:
		X[a] += 1
	m = 2
	ans = 0
	for (i, x) in enumerate(X):
		if m == 2:
			if x >= 2:
				continue
			if x == 1:
				m = 1
				ans += i
				continue
			ans += i * 2
			break
		if m == 1:
			if x >= 1:
				continue
			ans += i
			break
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s = sorted(set(a))
	i = 0
	B = 0
	if s[0] == 0:
		i += 1
		while i < len(s) and s[i] == s[i - 1] + 1:
			i += 1
		for x in range(i):
			if a.count(s[x]) < 2:
				break
			B += 1
	A = i
	print(A + B)


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	if s.count(0) == 0:
		print('0')
	elif s.count(0) == 1:
		f = 1
		for i in range(1, max(s)):
			if i not in s:
				f = 0
				print(i)
				break
		if f == 1:
			print(max(s) + 1)
	else:
		f = 1
		j = 0
		g = 0
		z = 0
		for i in range(1, max(s) + 1):
			if s.count(i) < 2:
				j = i - 1
				z = 1
				break
		if z == 0:
			j = max(s)
		for x in range(j, max(s) + 1):
			g = 1
			if x not in s:
				print(j + x + 1)
				f = 0
				break
		if g == 1 and f == 1:
			print(j + max(s) + 2)
		if g == 0 and f == 1:
			print(2 * (max(s) + 1))


import math as mt
import sys, string
from collections import Counter, defaultdict
input = sys.stdin.readline
I = lambda : int(input())
M = lambda : map(int, input().split())
ARR = lambda : list(map(int, input().split()))

def mex(arr):
	i = 0
	while True:
		if i not in arr:
			return i
		i += 1

def main():
	n = I()
	arr = ARR()
	arr.sort()
	(a, b) = ([], [])
	lst = -1
	for i in range(n):
		if lst + 1 == arr[i]:
			lst = arr[i]
			a.append(arr[i])
		else:
			b.append(arr[i])
	print(mex(a) + mex(b))
tc = I()
for _ in range(tc):
	main()


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	A = []
	B = []
	for i in a:
		if len(A) == 0 or i != A[-1]:
			A.append(i)
		else:
			B.append(i)
	count = 0
	for i in range(101):
		if i not in A:
			count += i
			break
	for i in range(101):
		if i not in B:
			count += i
			break
	print(count)


t = int(input())
for i in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	first = 0
	second = 0
	freq = [0 for j in range(101)]
	for j in range(n):
		freq[lst[j]] += 1
	for j in range(len(freq)):
		if freq[j] == 0:
			first = j
			break
		freq[j] -= 1
	for j in range(len(freq)):
		if freq[j] == 0:
			second = j
			break
		freq[j] -= 1
	print(first + second)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	mex = 0
	for i in range(n + 3):
		if i in a:
			a.pop(a.index(i))
		else:
			mex += i
			break
	for i in range(n + 3):
		if i not in a:
			mex += i
			break
	print(mex)


t = int(input())
for j in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	s = []
	for i in range(l[-1] + 2):
		s.append(0)
	for i in l:
		s[i] += 1
	a = []
	for i in range(len(s)):
		if s[i] > 0:
			a.append(i)
			s[i] -= 1
		else:
			break
	b = []
	for i in range(len(s)):
		if s[i] > 0:
			b.append(i)
			s[i] -= 1
		else:
			break
	print(len(a) + len(b))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	d = dict()
	for i in a:
		if d.get(i, None) == None:
			d[i] = 0
		d[i] += 1
	i = 0
	(fa, fb) = (True, True)
	ans = 0
	while fa or fb:
		if d.get(i, None) == None:
			if fa:
				ans = ans + i
			if fb:
				ans = ans + i
			break
		if d[i] >= 2:
			i += 1
			continue
		elif d[i] == 1:
			if fa:
				ans = ans + i
				fa = False
		i += 1
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	z = max(a) + 2
	b = [0] * (z + 2)
	t = 0
	for i in a:
		b[i] += 1
	for i in range(z):
		if b[i] <= 0:
			t = i
			for j in range(i):
				b[j] -= 1
			for j in range(z):
				if b[j] <= 0:
					t += j
					break
			break
	print(t)


cases = int(input())
for i in range(cases):
	n = int(input())
	l2 = input().split(' ')
	arr = []
	sol = 0
	for a in l2:
		arr.append(int(a))
	ss = []
	n1 = n2 = 0
	for b in range(0, 101):
		if b in arr:
			ss.append(b)
			arr.remove(b)
		else:
			n1 = b
			break
	for c in range(0, 101):
		if c not in arr:
			n2 = c
			break
	print(n1 + n2)


from collections import Counter
import sys
input = sys.stdin.readline
T = int(input())
for t in range(T):
	N = int(input())
	A = [int(_) for _ in input().split()]
	cc = Counter(A)
	f = None
	for i in range(101):
		if cc[i] >= 2:
			continue
		elif cc[i] == 1 and f is None:
			f = i
		elif cc[i] == 0:
			if f is None:
				f = i
			s = i
			break
	print(f + s)


for t in range(int(input())):
	n = map(int, input().split())
	l = list(map(int, input().split()))
	m = []
	k = []
	for i in range(0, 101):
		m.append(l.count(i))
		if m[i] == 1:
			k.append(i)
		elif m[i] == 0:
			if k:
				print(k[0] + i)
				break
			else:
				print(2 * i)
				break
		else:
			pass


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	m = len(set(arr))
	temp = list(range(n))
	arr = temp + arr
	freqs = list(Counter(arr).values())
	for i in range(m):
		freqs[i] -= 1
	i = 0
	while i < m and freqs[i] > 0:
		freqs[i] -= 1
		i += 1
	l = i
	i = 0
	while i < m and freqs[i] > 0:
		freqs[i] -= 1
		i += 1
	r = i
	print(l + r)


t = int(input())
for y in range(t):
	n = int(input())
	arr = [int(i) for i in input().split()]
	arr1 = [0 for i in range(n)]
	for i in range(n):
		if arr[i] < n:
			arr1[arr[i]] += 1
	ans = -1
	for i in range(n):
		if arr1[i] == 0:
			ans = i
			break
	if ans == -1:
		ans = n
	for j in range(ans):
		arr1[j] -= 1
	if ans < n and arr1[ans] != 0:
		arr1[ans] -= 1
	ele = -1
	for k in range(n):
		if arr1[k] == 0:
			ele = k
			break
	if ele == -1:
		ele = n
	print(ans + ele)


import sys
import math
from collections import defaultdict, Counter
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	c = Counter(a)
	ans = 0
	for j in range(101):
		if c.get(j, 0) == 0:
			ans += 2 * j
			break
		elif c.get(j, 0) == 1:
			ans += j
			for k in range(j + 1, 101):
				if c.get(k, 0) == 0:
					ans += k
					break
			break
	print(ans)


from sys import stdin, stdout
import math
t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	dict = {}
	for i in range(0, 102):
		dict[i] = 0
	for i in arr:
		dict[i] += 1
	ans = 0
	b = 0
	for i in range(0, 102):
		if b:
			if dict[i] == 0:
				ans += i
				break
			continue
		if dict[i] == 0:
			ans += 2 * i
			break
		elif dict[i] == 1:
			ans += i
			b = 1
	print(ans)


from collections import Counter
t = int(input())
buf = []
for _ in range(t):
	n = int(input())
	cnt = Counter(map(int, input().split()))
	(a, b) = (-1, -1)
	for i in range(101):
		if cnt[i] < 1:
			if a == -1:
				a = b = i
			else:
				b = i
			break
		elif cnt[i] < 2:
			if a == -1:
				a = i
	buf.append(a + b)
print('\n'.join(map(str, buf)))


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	c = [0] * 101
	for i in l:
		c[i] += 1
	(n1, n2) = (0, 0)
	i = 0
	while i < len(l) and c[i] >= 2:
		i += 1
	n1 = i
	while i < len(l) and c[i] >= 1:
		i += 1
	n2 = i
	print(n1 + n2)


from collections import *
for u in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	d = defaultdict(int)
	for i in l:
		d[i] += 1
	(x, y) = ([], [])
	f = 0
	for i in d:
		if d[i] % 2 == 0:
			x.append(i)
			y.append(i)
		elif d[i] == 1:
			x.append(i)
		else:
			x.append(i)
			y.append(i)
	x.sort()
	y.sort()
	(xx, yy) = (0, 0)
	for i in x:
		if i == xx:
			xx += 1
		else:
			break
	for i in y:
		if i == yy:
			yy += 1
		else:
			break
	print(xx + yy)


from sys import *
t = int(stdin.readline())
while t:
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	cnt = [0 for i in range(101)]
	for ele in a:
		cnt[ele] += 1
	a = 0
	b = 0
	for i in range(101):
		if cnt[i] == 0:
			a = i
			break
	for i in range(101):
		if cnt[i] < 2:
			b = i
			break
	print(a + b)
	t -= 1


import collections
for t in range(int(input())):
	n = int(input())
	num = sorted(map(int, input().split()), reverse=True)
	k = collections.defaultdict(int)
	for i in num:
		k[i] += 1
	count = 2
	out = 0
	base = 0
	for i in sorted(k.keys()):
		if base != i:
			out += base * count
			count = 0
			break
		if k[i] == 1:
			if count == 2:
				out += base
				count -= 1
		base += 1
	if count:
		out += base * count
	print(out)


for _ in range(int(input())):
	k = int(input())
	a = list(map(int, input().split()))
	a.sort()
	elem = []
	s1 = set()
	s2 = set()
	flag = 0
	for i in range(k + 1):
		if a.count(i) == 0:
			if flag:
				elem.append(i)
			else:
				elem.append(i)
				elem.append(i)
			break
		if a.count(i) == 1 and flag == 0:
			elem.append(i)
			flag = 1
	print(elem[0] + elem[1])


testcases = int(input())
for testcase in range(testcases):
	n = int(input())
	temparr = input()
	temparr = temparr.split()
	arr = []
	for i in temparr:
		arr.append(int(i))
	arr = sorted(arr)
	dictsa = {}
	dictsb = {}
	flag = 0
	prev = 0
	for i in arr:
		if i not in dictsa:
			dictsa[i] = 1
		else:
			dictsb[i] = 1
	ans = 0
	for i in range(0, n + 2):
		if i not in dictsa:
			ans += i
			break
	for i in range(0, n + 2):
		if i not in dictsb:
			ans += i
			break
	print(ans)


for _ in range(int(input())):
	n = int(input())
	ara = list(map(int, input().strip().split()))
	ara.sort()
	a = set()
	b = set()
	a.add(ara[0])
	for i in range(1, n):
		if ara[i] == ara[i - 1]:
			b.add(ara[i])
		else:
			a.add(ara[i])
	ans = count = flag = 0
	for i in a:
		if i == count:
			count += 1
			flag = 1
		else:
			ans += count
			flag = 0
			break
	if flag == 1:
		ans += count
	count = flag = 0
	for i in b:
		if i == count:
			count += 1
			flag = 1
		else:
			ans += count
			flag = 0
			break
	if flag == 1:
		ans += count
	print(ans)


def _mex(_array_):
	if len(_array_) == 0:
		return 0
	for i in range(0, max(_array_) + 2):
		if i not in _array_:
			return i
		else:
			pass
	return 0
t = int(input())
while t:
	lnegth_of_set = input()
	arr = [int(x) for x in input().split()]
	first_sub_set = []
	second_sub_set = []
	for i in arr:
		if i in first_sub_set:
			second_sub_set.append(i)
		else:
			first_sub_set.append(i)
	first_sub_set.sort()
	second_sub_set.sort()
	first_mex = _mex(first_sub_set)
	second_mex = _mex(second_sub_set)
	print(first_mex + second_mex)
	t -= 1
exit()


from collections import Counter
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
import math
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
inf = float('inf')
(t,) = gil()
for _ in range(t):
	(n,) = gil()
	a = gil()
	b = Counter(a)
	ans = []
	for i in range(max(a) + 2):
		if i not in b:
			ans.append(i)
			break
	b[i] = 1
	for i in range(max(a) + 2):
		if i not in b or b[i] <= 1:
			ans.append(i)
			break
	print(ans[0] + ans[1])


for _ in range(int(input())):
	am = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	counter = [0] * (max(arr) + 2)
	for i in range(am):
		counter[arr[i]] += 1
	arr1 = [0] * (max(arr) + 2)
	arr2 = [0] * (max(arr) + 2)
	for i in range(len(counter)):
		if counter[i] > 0:
			arr1[i] = 1
		if counter[i] > 1:
			arr2[i] = 1
	s = 0
	for i in range(len(arr1)):
		if arr1[i] == 0:
			s += i
			break
	for i in range(len(arr2)):
		if arr2[i] == 0:
			s += i
			break
	print(s)


from collections import Counter as C
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = dict(C(a))
	(x, c) = (0, 0)
	for i in range(101):
		if i in d:
			if d[i] < 2 and x != 1:
				c += i
				x += 1
		else:
			c += i * (2 - x)
			break
	print(c)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	l = Counter(map(int, input().split()))
	(a, b) = (-1, -1)
	for i in range(n + 1):
		if l[i] == 1:
			if a == -1:
				a = i
		if l[i] == 0:
			if a == -1:
				a = i
			if b == -1:
				b = i
	print(a + b)


t = int(input())
for z in range(t):
	n = int(input())
	arr = input()
	arr = arr.split()
	a = []
	for i in range(n):
		a.append(int(arr[i]))
	s = [0] * 101
	for i in range(n):
		s[a[i]] += 1
	ans = 0
	for i in range(101):
		if s[i] > 1:
			continue
		ans += i
		break
	for i in range(101):
		if s[i] > 0:
			continue
		ans += i
		break
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	(res, check, ind) = (0, 0, 0)
	for i in range(0, max(a) + 2):
		if a.count(i) == 1:
			if check == 0:
				check = 1
				ind += 1
				res += i
			elif check == 1:
				continue
		elif a.count(i) == 0:
			if check == 0:
				res += 2 * i
				ind += 2
			elif check == 1:
				res += i
				ind += 1
		if ind >= 2:
			break
	print(res)


from collections import Counter
y122 = int(input())
for _ in range(y122):
	a = input()
	a = Counter(map(int, input().strip().split()))
	b = 0
	c = 0
	d = 2
	for i in range(101):
		try:
			qw = a[i]
		except:
			a[i] = 0
		if a[i] < 2:
			if d == 2:
				if a[i] == 1:
					b = i
					d -= 1
				else:
					b = i
					c = i
					break
			elif a[i] < 1:
				c = i
				break
	print(b + c)


for _ in range(int(input())):
	n = int(input())
	ar = sorted(list(map(int, input().split())))
	t = max(ar)
	ar1 = []
	for i in range(n):
		if ar[i] not in ar1:
			ar1.append(ar[i])
			ar[i] = -1
	ar2 = []
	for i in ar:
		if i >= 0:
			ar2.append(i)
	ans1 = 0
	ans2 = 0
	for i in range(0, 101):
		if i in ar2:
			pass
		else:
			ans1 = i
			break
	for j in range(0, 101):
		if j in ar1:
			pass
		else:
			ans2 = j
			break
	print(ans1 + ans2)


t = int(input())
for _ in range(t):
	n = int(input())
	a = []
	b = []
	l = list(map(int, input().split()))
	l.sort()
	c1 = 0
	c2 = 0
	for i in l:
		if i not in a:
			a.append(i)
		elif i not in b:
			b.append(i)
	for i in range(len(a)):
		if c1 == a[i]:
			c1 += 1
		else:
			break
	for i in range(len(b)):
		if c2 == b[i]:
			c2 += 1
		else:
			break
	print(c1 + c2)


def DD(W):
	if len(W) == 0:
		return 0
	else:
		for p in range(len(W)):
			if p in W:
				pass
			else:
				return p
		return p + 1
t = int(input())
for i in range(t):
	N = int(input())
	A = list(map(int, input().split()))
	B = sorted(A)
	C = []
	D = []
	Z = 0
	for j in range(len(B)):
		if B[j] in C:
			pass
		else:
			C.append(B[j])
			A.remove(B[j])
	m = DD(C)
	n = DD(A)
	print(m + n)


ct = input()
for line in range(int(ct)):
	x = input()
	n = [int(i) for i in input().split()]
	first = []
	second = []
	for i in n:
		if i not in first:
			first.append(i)
		else:
			second.append(i)
	for k in range(101):
		if k not in first:
			fFinal = k
			break
	for k in range(101):
		if k not in second:
			sFinal = k
			break
	print(fFinal + sFinal)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	N = int(input())
	nums = [0] * 101
	for i in map(int, input().split()):
		nums[i] += 1
	mexA = mexB = 0
	for i in range(101):
		if nums[i] == 0:
			mexA = i
			break
		nums[i] -= 1
	for i in range(101):
		if nums[i] == 0:
			mexB = i
			break
	print(mexA + mexB)


from sys import stdin, stdout
from collections import defaultdict as dd
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	d = dd(int)
	for i in a:
		d[i] += 1
	fl = 0
	ans = 0
	for i in range(102):
		if fl >= 2:
			break
		if fl == 0 and d[i] == 1:
			ans += i
			fl += 1
		if d[i] == 0:
			if fl == 0:
				ans += 2 * i
				fl = 2
			else:
				ans += i
				fl = 2
	print(ans)


a = int(input())
for i in range(a):
	sum = 0
	k = 1
	b = int(input())
	c = input().split()
	c = sorted(c)
	for j in range(b + 1):
		if str(j) not in c:
			sum += j
			if k == 1:
				print(sum + j)
			else:
				print(sum)
			break
		if (c.count(str(j)) == 1 or c.count(str(j)) == 0) and k == 1:
			sum += j
			k -= 1