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)
    # print(freq)
    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
        else:
            break

    print(onerun+1 + tworun+1)


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)
    # print(freq)
    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
        else:
            break

    print(onerun+1 + tworun+1)


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 collections import Counter
# c=sorted((i,int(val))for i,val in enumerate(input().split()))
import heapq
import math
# c=sorted((i,int(val))for i,val in enumerate(input().split()))
#n=int(input())
#arr = list(map(int, input().split()))
#sys.stdout.flush()
#n,x= map(int, input().split())
for _ in range(int(input())):
    n=int(input())
    arr = list(map(int, input().split()))
    ans=0
    arr=sorted(arr)
    ls=[]
    ls1=[]
    #c=Counter(arr)
    if n%2==1:
        print(0)
    else:
        cnt1=0
        cnt2=0
        f=0
        for i in range(n):
            if f==0:
                ls.append(arr[i])
                f=1
            else:
                f=0
                ls1.append(arr[i])
        f=0
        flag=0

        for i in range(n):
            if f==0:
                if ls[i]!=i:
                    ans+=i
                    f=1
            if flag==0:
                if ls1[i]!=i:
                    ans+=i
                    flag=1
            if f==1 and flag==1:
                break
        print(ans)


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 collections import Counter
# c=sorted((i,int(val))for i,val in enumerate(input().split()))
import heapq
import math
# c=sorted((i,int(val))for i,val in enumerate(input().split()))
#n=int(input())
#arr = list(map(int, input().split()))
#sys.stdout.flush()
#n,x= map(int, input().split())
for _ in range(int(input())):
    n=int(input())
    arr = list(map(int, input().split()))
    ans=0
    arr=sorted(arr)
    ls = []
    ls1 = []

    f = 0
    for i in range(n):
        if f == 0:
            ls.append(arr[i])
            f = 1
        else:
            f = 0
            ls1.append(arr[i])
    f = 0
    flag = 0
    ans = 0
    for i in range(n // 2):
        if f == 0:
            if i<len(ls) and ls[i] != i:
                ans += i
                f = 1
        if flag == 0:
            if i<len(ls1) and ls1[i] != i:
                ans += i
                flag = 1
        if f == 1 and flag == 1:
            break
    if f == 0:
        ans += ls[-1] + 1
    if flag == 0:
        ans += ls1[-1] + 1

    print(ans)
    #c=Counter(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 collections import Counter
# c=sorted((i,int(val))for i,val in enumerate(input().split()))
import heapq
import math
# c=sorted((i,int(val))for i,val in enumerate(input().split()))
#n=int(input())
#arr = list(map(int, input().split()))
#sys.stdout.flush()
#n,x= map(int, input().split())
for _ in range(int(input())):
    n=int(input())
    arr = list(map(int, input().split()))
    ans=0
    arr=sorted(arr)
    c=Counter(arr)
    ls = []
    ls1 = []

    f = 0
    for i in range(n):
        if f == 0:
            ls.append(arr[i])
            f = 1
        else:
            f = 0
            ls1.append(arr[i])
    f = 0
    flag = 0
    ans = 0
    for i in range(n // 2):
        if f == 0:
            if i<len(ls) and ls[i] != i:
                ans += i
                f = 1
        if flag == 0:
            if i<len(ls1) and ls1[i] != i:
                ans += i
                flag = 1
        if f == 1 and flag == 1:
            break
    if f == 0:
        ans += ls[-1] + 1
    if flag == 0:
        ans += ls1[-1] + 1
    cnt=0
    for i in range(1,101):
        if i>=n:
            break
        if arr[i]==cnt:
            cnt+=1
    cnt1=0
    ss=sorted(set(arr))
    for i in c:
        if i>=len(ss):
            break
        if c[ss[i]]>1:
            if ss[i]==cnt1:
                cnt1+=1

    print(max(ans,cnt+cnt1))
    #c=Counter(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 collections import Counter
# c=sorted((i,int(val))for i,val in enumerate(input().split()))
import heapq
import math
# c=sorted((i,int(val))for i,val in enumerate(input().split()))
#n=int(input())
#arr = list(map(int, input().split()))
#sys.stdout.flush()
#n,x= map(int, input().split())
for _ in range(int(input())):
    n=int(input())
    arr = list(map(int, input().split()))
    ans=0
    arr=sorted(arr)
    c=Counter(arr)
    ls = []
    ls1 = []

    f = 0
    for i in range(n):
        if f == 0:
            ls.append(arr[i])
            f = 1
        else:
            f = 0
            ls1.append(arr[i])
    f = 0
    flag = 0
    ans = 0
    for i in range(n // 2):
        if f == 0:
            if i<len(ls) and ls[i] != i:
                ans += i
                f = 1
        if flag == 0:
            if i<len(ls1) and ls1[i] != i:
                ans += i
                flag = 1
        if f == 1 and flag == 1:
            break
    if f == 0:
        ans += ls[-1] + 1
    if flag == 0:
        ans += ls1[-1] + 1
    cnt=0
    for i in range(1,101):
        if i>=n:
            break
        if arr[i]==cnt:
            cnt+=1
    cnt1=0
    ss=sorted(set(arr))
    for i in range(len(ss)):
        if c[ss[i]]>1:
            if ss[i]==cnt1:
                cnt1+=1

    print(max(ans,cnt+cnt1))
    #c=Counter(arr)


from collections import Counter
for _ in range(int(input())):
    n=int(input())
    arr = list(map(int, input().split()))
    ans=0
    arr=sorted(arr)
    c=Counter(arr)
    ans=0
    f=0
    for i in range(max(arr)+1):
        if c[i]==0:
            f=1
            ans=2*i

    if f==1:
        print(ans)
    else:
        f=0
        ans=0
        flag=0
        for i in range(n):
            if f==0:
                if c[arr[i]]==1:
                    ans+=arr[i]
                    f=1
                    break
        print(ans+max(arr)+1)


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 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()
    cur = 0
    ans = 0
    for i in range(n-1):
        if a[i] == cur:
            ans += 1
            cur += 1
        if a[i+1] == cur-1:
            ans += 1
    if a[n-1] == cur:
        ans += 1
    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)


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())
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]:
                b.append(x[i])
            else:
                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


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())
    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
    for i in range(max(arr)+1):
        if i in d:
            if d[i] > 1:
                mexa = i+1
                mexb = i+1
            else:
                mexa = i+1
        else:
            break
    print(mexa+mexb)


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()

        first_num = -1
        second_num = -1
        for i in range(num_count):
            num_count = nums.count(i)

            if num_count >= 2:
                first_num = i
                second_num = i
            elif num_count == 1:
                second_num = i
            else:
                break

        print(first_num + second_num + 2)
run()


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()

        first_num = -1
        second_num = -1
        for i in range(num_count):
            num_count = nums.count(i)

            if num_count == 2:
                first_num = i
                second_num = i
            elif num_count == 1:
                second_num = i
            else:
                break

        print(first_num + second_num + 2)
run()


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()


"""
- math -
from math import factorial
from math import gcd
from math import pi
large_p = 10**9 + 7
from itertools import accumulate # 累積和
from operator import mul
- other -
from collections import Counter
from itertools import combinations
from itertools import combinations_with_replacement
from itertools import permutations
from operator import itemgetter
from functools import reduce
- list -
from copy import deepcopy
from collections import deque
from heapq import heapify, heappop, heappush
- output -
p2d = lambda x: print(*x, sep="\n")
p2line = lambda x: print(*x, sep=" ")
print(*list1, sep="\n")
- input -
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
= map(int, input().split())
= [tuple(map(int, input().split())) for _ in range(n)]
m = map(int, read().split()) /ab = zip(m, m) /for a, b in ab:
ps = [line.split() for line in readlines()] # inputの最後まで読んでしまうので注意。
n, k, *h = map(int, read().split())
a = tuple(map(int, readlines()))
a = np.array(read().split(), np.int32)
- run -
sys.setrecursionlimit(10**6)
from time import sleep
from numba import njit
import numpy as np
"""
# ATC05

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
                else:
                    if flag:
                        r1 = cnt + 1
                    else:
                        r1 = cnt + 1
                        r2 = cnt + 1
                cnt += 1
            print(r1 + r2)

if __name__ == '__main__':
    main()


"""
- math -
from math import factorial
from math import gcd
from math import pi
large_p = 10**9 + 7
from itertools import accumulate # 累積和
from operator import mul
- other -
from collections import Counter
from itertools import combinations
from itertools import combinations_with_replacement
from itertools import permutations
from operator import itemgetter
from functools import reduce
- list -
from copy import deepcopy
from collections import deque
from heapq import heapify, heappop, heappush
- output -
p2d = lambda x: print(*x, sep="\n")
p2line = lambda x: print(*x, sep=" ")
print(*list1, sep="\n")
- input -
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
= map(int, input().split())
= [tuple(map(int, input().split())) for _ in range(n)]
m = map(int, read().split()) /ab = zip(m, m) /for a, b in ab:
ps = [line.split() for line in readlines()] # inputの最後まで読んでしまうので注意。
n, k, *h = map(int, read().split())
a = tuple(map(int, readlines()))
a = np.array(read().split(), np.int32)
- run -
sys.setrecursionlimit(10**6)
from time import sleep
from numba import njit
import numpy as np
"""
# ATC05

import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import deque
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)
            sys.exit()
        a = deque(a)
        r1 = 0
        r2 = 0
        while a:
            na = a.popleft()
            if r1 == na:
                r1 += 1
            elif r2 == na:
                r2 += 1
        print(r1 + r2)

if __name__ == '__main__':
    main()


"""
- math -
from math import factorial
from math import gcd
from math import pi
large_p = 10**9 + 7
from itertools import accumulate # 累積和
from operator import mul
- other -
from collections import Counter
from itertools import combinations
from itertools import combinations_with_replacement
from itertools import permutations
from operator import itemgetter
from functools import reduce
- list -
from copy import deepcopy
from collections import deque
from heapq import heapify, heappop, heappush
- output -
p2d = lambda x: print(*x, sep="\n")
p2line = lambda x: print(*x, sep=" ")
print(*list1, sep="\n")
- input -
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
= map(int, input().split())
= [tuple(map(int, input().split())) for _ in range(n)]
m = map(int, read().split()) /ab = zip(m, m) /for a, b in ab:
ps = [line.split() for line in readlines()] # inputの最後まで読んでしまうので注意。
n, k, *h = map(int, read().split())
a = tuple(map(int, readlines()))
a = np.array(read().split(), np.int32)
- run -
sys.setrecursionlimit(10**6)
from time import sleep
from numba import njit
import numpy as np
"""
# ATC05

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
            print(ac.items())
            for k, v in ac.items():
                if k != cnt:
                    break
                if v <= 1:
                    r1 = cnt + 1
                    flag = True
                else:
                    if flag:
                        r1 = cnt + 1
                    else:
                        r1 = cnt + 1
                        r2 = cnt + 1
                cnt += 1
            print(r1 + r2)

if __name__ == '__main__':
    main()


"""
- math -
from math import factorial
from math import gcd
from math import pi
large_p = 10**9 + 7
from itertools import accumulate # 累積和
from operator import mul
- other -
from collections import Counter
from itertools import combinations
from itertools import combinations_with_replacement
from itertools import permutations
from operator import itemgetter
from functools import reduce
- list -
from copy import deepcopy
from collections import deque
from heapq import heapify, heappop, heappush
- output -
p2d = lambda x: print(*x, sep="\n")
p2line = lambda x: print(*x, sep=" ")
print(*list1, sep="\n")
- input -
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
= map(int, input().split())
= [tuple(map(int, input().split())) for _ in range(n)]
m = map(int, read().split()) /ab = zip(m, m) /for a, b in ab:
ps = [line.split() for line in readlines()] # inputの最後まで読んでしまうので注意。
n, k, *h = map(int, read().split())
a = tuple(map(int, readlines()))
a = np.array(read().split(), np.int32)
- run -
sys.setrecursionlimit(10**6)
from time import sleep
from numba import njit
import numpy as np
"""
# ATC05

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)
            sys.exit()
        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
            else:
                if flag:
                    r1 = cnt + 1
                else:
                    r1 = cnt + 1
                    r2 = cnt + 1
            cnt += 1

        print(r1 + r2)

if __name__ == '__main__':
    main()


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)


import sys
# input = raw_input
input = sys.stdin.readline

# range = xrange
def answer(arr):
    ans = 0
    f = True
    if(len(arr)==0):
        return 0
    st = min(arr)
    en = max(arr)
    ar1 = [i for i in range(st,en+1)]
    # print(ar1,arr)/
    if(ar1==arr):
        return 0 if arr[0]!=0 else arr[-1]+1
    for i,j in zip(ar1,arr):
        if(i!=j):
            ans = i
            break

    return ans

from collections import Counter
from math import sqrt,ceil,floor
for t in range(int(input())):
    n = int(input())
    arr = [int(i) for i in input().split()]
    arr = sorted(arr)
    d = Counter(arr)
    set1 = set()
    set2 = set()
    for i,j in d.items():
        if(j!=0):
            set1.add(i)
            d[i]-=1
    for i,j in d.items():
        if(j!=0):
            set2.add(i)
    set1 = list(set1)
    set2 = list(set2)
    ans1 = answer(set1)
    ans2 = answer(set2)
    print(ans1+ans2)
    # print(set1,set2)


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


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)


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


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


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)


t = int(input())
for _ in range(t):
    n = int(input())
    a = [int(x) for x in input().split()]
    a.sort()
    # s = set(a)
    # if(len(s)==1):
    #     if(a[0]==0):
    #         print(2)
    #     else:
    #         print(0)
    #     continue
    # elif(len(s)==n and a[0]==1):
    #     print(0)
    #     continue
    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 and dic[i]==0):
            temp = 1
            res = 2*i
        elif((temp==False) and dic[i]==1):
            continue
        elif((temp==False) and dic[i]==0):
            res += i
            break
    print(res)


t = int(input())
for _ in range(t):
    n = int(input())
    a = [int(x) for x in input().split()]
    # a.sort()
    # s = set(a)
    # if(len(s)==1):
    #     if(a[0]==0):
    #         print(2)
    #     else:
    #         print(0)
    #     continue
    # elif(len(s)==n and a[0]==1):
    #     print(0)
    #     continue
    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):
            # temp = 1
            res = 2*i
        elif((temp==False) and dic[i]==1):
            continue
        elif((temp==False) and dic[i]==0):
            res += i
            break
    print(res)


t = int(input())
for _ in range(t):
    n = int(input())
    a = [int(x) for x in input().split()]
    # a.sort()
    # s = set(a)
    # if(len(s)==1):
    #     if(a[0]==0):
    #         print(2)
    #     else:
    #         print(0)
    #     continue
    # elif(len(s)==n and a[0]==1):
    #     print(0)
    #     continue
    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):
            # temp = 1
            res = 2*i
            break
        elif((temp==False) and dic[i]==1):
            continue
        elif((temp==False) and dic[i]==0):
            res += i
            break
    print(res)


t = int(input())
for _ in range(t):
    n = int(input())
    a = [int(x) for x in input().split()]
    # a.sort()
    # s = set(a)
    # if(len(s)==1):
    #     if(a[0]==0):
    #         print(2)
    #     else:
    #         print(0)
    #     continue
    # elif(len(s)==n and a[0]==1):
    #     print(0)
    #     continue
    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):
            temp = 1
            res = 2*i
        elif((temp==False) and dic[i]==1):
            continue
        elif((temp==False) and dic[i]==0):
            res += i
            break
    print(res)


# ------------------- fast io --------------------
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")
# ------------------- fast io --------------------
for j in range(int(input())):
    n=int(input());vals=list(map(int,input().split()))
    if n==1:
        print(vals[0])
    else:
        print(min(vals)+max(vals))


# ------------------- fast io --------------------
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")
# ------------------- fast io --------------------
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))


##from collections import Counter
t=int(input())
while(t):
    t-=1
    n=int(input())

    m=[0]*(n+1)
    z=list(map(int,input().strip().split()))[:n]
    for x in z:
        if x<=n:
            m[x]+=1

    ans=0
    w=0
    for j in range(n+1):
        if w==2:
            break
        if w==0 and m[j]==1:
            w=1
            ans+=j
        elif w==0 and m[j]==0:
            w=2
            ans+=2*j
        elif w==1 and m[j]<1:
            w=2
            ans+=j

    print(ans)


##from collections import Counter
t=int(input())
while(t):
    t-=1
    n=int(input())

    m=[0]*(n+1)
    z=list(map(int,input().strip().split()))[:n]
    for x in z:
        if x<=n:
            m[x]+=1

    ans=0
    w=0
    for j in range(n+1):
        if w==2:
            break
        if w==0 and m[j]<2:
            w=1
            ans+=j
        elif w==1 and m[j]<1:
            w=2
            ans+=j

    print(ans)


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)
    arra = []
    arrb = []
    flag = 0
    prev = 0
    for i in range( n ):
        if i & 1 == 0 :
            arra.append(arr[i])
        else:
            if arra[-1] == arr[i]:
                arrb.append(arr[i])
            else:
                arra.append(arr[i])
    lenga = len(arra)
    lengb = len(arrb)
    dictsa = {}
    dictsb = {}
    for i in arra:
        if i not in dictsa:
            dictsa[i] = 1
        else:
            dictsa[i] += 1
    for i in arrb:
        if i not in dictsb:
            dictsb[i] = 1
        else:
            dictsb[i] += 1
    ans = 0
    if lenga != 0 :
        for i in range(lenga + 2):
            if i not in dictsa:
                ans += i
                break
    if lengb != 0 :
        for i in range(lengb + 2):
            if i not in dictsb:
                ans += i
                break
    print(ans)


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)
    #     if i & 1 == 0 :
    #         arra.append(arr[i])
    #     else:
    #         if arra[-1] == arr[i]:
    #             arrb.append(arr[i])
    #         else:
    #             arra.append(arr[i])
    # lenga = len(arra)
    # lengb = len(arrb)
    # dictsa = {}
    # dictsb = {}
    # for i in arra:
    #     if i not in dictsa:
    #         dictsa[i] = 1
    #     else:
    #         dictsa[i] += 1
    # for i in arrb:
    #     if i not in dictsb:
    #         dictsb[i] = 1
    #     else:
    #         dictsb[i] += 1
    # ans = 0
    # if lenga != 0 :
    #     for i in range(lenga + 2):
    #         if i not in dictsa:
    #             ans += i
    #             break
    # if lengb != 0 :
    #     for i in range(lengb + 2):
    #         if i not in dictsb:
    #             ans += i
    #             break
    # print(arra)
    # print(arrb)
    # print(ans)


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(100):
            if d[i]>0:
                d[i]-=1
            else:
                s+=i
                break
    print(s)


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)


from collections import defaultdict
for _ in range(int(input())):
    n = int(input())
    a = list(map(int, input().split()))

    oc = defaultdict(int)
    for i in a:
        oc[i]+=1
    s = 0
    t = 0
    for i in range(100):
        if t == 2:
            break
        if oc[i] == 0:
            if t == 0:
                s+=2*i
            else:
                s+=i
            break
        if oc[i]==1 and t ==0:
            s+=i
            t+=1
    print(s)


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>amax):
                i-=1
                another_flag=1

            if i not in a and flag==0:
                first=i;
                flag+=1
            if a.count(i)==1 and flag==0:
                first=i
                flag+=1

            if i not in a and flag==1 and (first!=i or another_flag==1):
                second=i
                flag+=1
            # if a.count(i)<=1 and flag==1 and first!=i:
            #     second=i
            #     flag+=1
            if flag==2:
                break

        print(first+second)


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>amax):
        #         i-=1
        #         another_flag=1
        #
        #     if i not in a and flag==0:
        #         first=i;
        #         flag+=1
        #     if a.count(i)==1 and flag==0:
        #         first=i
        #         flag+=1
        #
        #
        #     if i not in a and flag==1 and (first!=i or another_flag==1):
        #         second=i
        #         flag+=1
        #     # if a.count(i)<=1 and flag==1 and first!=i:
        #     #     second=i
        #     #     flag+=1
        #     if flag==2:
        #         break
        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 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)


from collections import Counter,defaultdict,deque
for _ in range(int(input())):
  n=int(input())
  a=list(map(int,input().split()))
  a.sort();ans=0
  d=defaultdict(int)
  for i in range(len(a)):
    d[a[i]]+=1
  if a[0]!=0:
    print(0)
  else:
    c=0
    for i in range(1,100):
      if d[i]==1:
        ans+=i;c+=1
      elif d[i]==0:
        if ans==0:
          ans+=(2*i)
        else:
          ans+=(i)
        c+=2
      if c>=2:
        break
    print(ans)


from math import *
from bisect import *
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()
  a=LI()
  a=list(set(a))
  a.sort();flag=1
  for i in range(len(a)):
    if i<a[i]:
      print(i);flag=0;break
  if flag:
    print(a[-1]+1)


from math import *
from bisect import *
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()
  a=LI()
  b=[]
  c=[]
  a.sort()
  d=Counter(a)
  for i in d.keys():
    b+=[i]*(d[i]//2)
    b+=[i]*(d[i]%2)
    c+=[i]*(d[i]//2)
  ans=0;flag=1
  for i in range(len(b)):
    if b[i]!=i:
      ans+=i;flag=0;break
    if i==len(b)-1 and flag:
      ans+=(i+1)
  flag=1
  for i in range(len(c)):
    if c[i]!=i:
      ans+=i;break
    if i==len(c)-1 and flag:
      ans+=(i+1)
  print(ans)


for _ in range(int(input())):
    n = int(input())
    a = sorted(list(map(int,input().split())))
    ch = 0
    low = []
    c = 0
    for i in range(n+2):
        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
    low[2] = low[0]+low[2]
    low[1] = low[0]+low[1]
    low[0] = low[0]+low[0]
    print(min(low))


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
    low[2] = low[0]+low[2]
    low[1] = low[0]+low[1]
    low[0] = low[0]+low[0]
    print(min(low))


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))


for _ in range(int(input())):
    n = int(input())
    a = sorted(list(map(int,input().split())))
    ch = 0
    low = []
    c = 0
    for i in range(101):
        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
    low[2] = low[0]+low[2]
    low[1] = low[0]+low[1]
    low[0] = low[0]+low[0]
    print(min(low))


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
    if c1==0:
        s+=j
    j=0
    c1=0
    for i in l2:
        if i==j:
            j+=1
        else:
            s+=j
            c1=1
    if c1==0:
        s+=j
    print(s)


from collections import deque
import copy
def su(l):
    s1=0
    s2=0
    for i in range(len(l)):
        if i%2==0:
            s1+=l[i]
        else:
            s2+=l[i]
    if s1==s2:
        return True
    else:
        return False

for i in range(int(input())):
    n=int(input())
    l=list(map(int,input().split()))
    l=deque(l)
    ll=copy.deepcopy(l)
    while su(l)==False:
        l.popleft()
    if su(l)and len(l)!=0:
        print(len(l))
        for i in l:
            print(i,end=' ')
        print()
    elif len(l)==0:
        l=copy.deepcopy(ll)
        while su(l)==False:
            l.pop()
        if su(l):
            print(len(l))
            for i in l:
                print(i,end=' ')
            print()


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())
	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()))
	mx = 0
	for i in range(n):
		b = set(a[0:i])
		c = set(a[i:])
		ans = 0
		for j in range(len(b)+1):
			if(j not in b):
				ans += j
				break
		for j in range(len(c)+1):
			if(j not in c):
				ans += j
				break
		mx = max(mx, ans)
	print(mx)


t = int(input())

for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	mx = 0
	for i in range(n):
		b = set(a[0:i])
		c = set(a[i:])
		ans = 0
		for j in range(len(b)):
			if(j not in b):
				ans += j
				break
			if(j == len(b)-1):
				ans += j+1
		for j in range(len(c)):
			if(j not in c):
				ans += j
				break
			if(j == len(c)-1):
				ans += j+1
		mx = max(mx, ans)
	print(mx)


# import sys
# input = lambda: sys.stdin.readline().rstrip()
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()
  if a[0]==0:
    c = [a[0]]
    ans = 0
    I = []
    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.pop(0)
    # print(a)
    if a!=[]:
      d = [a[0]]
      for i in range(len(a)):
        if d[-1]!=a[i] and a[i]==d[-1]+1:
          d.append(a[i])
    #   print(c,d)
      print(d[-1]+c[-1]+2)
    else:
      print(c[-1]+1)

  else:
    print(0)


# import sys
# input = lambda: sys.stdin.readline().rstrip()
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()
  if a[0]==0:
    c = [a[0]]
    ans = 0
    I = []
    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.pop(0)
    print(a)
    if a!=[]:
      d = [a[0]]
      for i in range(len(a)):
        if d[-1]!=a[i] and a[i]==d[-1]+1:
          d.append(a[i])
      print(c,d)
      print(d[-1]+c[-1]+2)
    else:
      print(c[-1]+1)

  else:
    print(0)


# import sys
# input = lambda: sys.stdin.readline().rstrip()
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()
  # a.append(10**4)
  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(a,c)
  print(ans)


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-7):
	""" Locate the first value x s.t. func(x) = True within [lo, hi] """
	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-7):
	""" Find maximum of unimodal function func() within [lo, hi] """
	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):
	""" Locate the first value x s.t. func(x) = True within [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):
	""" Find the first maximum of unimodal function func() within [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
		#Relax all the neighbours of u
		for t in E[u]:
			v,r=t
			if dist[v]>d+r:
				dist[v]=d+r
				hq.heappush(queue,(dist[v],v))
		#Node u has been processed
		visited.add(u)
	return dist

def prime_sieve(n):
	"""returns a sieve of primes >= 5 and < 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):
	"""returns a list of primes <= 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):
	""" Uses Dijkstra's algortihm to find the shortest path between in a graph. """
	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):
	"""
	finds a shortest path in undirected `graph` between `start` and `goal`.
	If no path is found, returns `None`
	"""
	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  # no path found. not strictly needed

def fillPrefixSum(arr,n,prefixSum):
	prefixSum[0]=arr[0]

	# Adding present element
	# with previous element
	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

'''for _ in range(int(input())):
	n,m=list(map(int,input().split()))
	graph=defaultdict(list)
	distance=[-1]*(n+1)
	visited=[False]*(n+1)
	for _ in range(m):
		x,y=list(map(int,input().split()))
		graph[x].append(y)
		graph[y].append(x)'''
'''for _ in range(int(input())):
	n,m=list(map(int,input().split()))
	graph=[[]for _ in range(n+1)]
	distance=[-1]*(n+1)
	visited=[False]*(n+1)
	for _ in range(m):
		x,y,w=list(map(int,input().split()))
		graph[x].append([y,w])
		graph[y].append([x,w])'''

import os
import sys
from io import BytesIO,IOBase

def DecimalToBinary(n):
	def helper(n):
		if n==0:
			return ''  # <- empty string
		else:
			if n%2==1:
				binaryDigit='1'
			else:
				binaryDigit='0'
			return helper(n//2)+binaryDigit

	if n==0:
		result='0'  # <- "leading zero" only for `n == 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):
	# Sort the array
	arr.sort()

	# find the max frequency using
	# linear traversal
	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 last element is most frequent
	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]

	# returns the length of the LDS
	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()
		d={}
		ans=0
		for i in range(0,100):
			d[i]=0
		for i in a:
			d[i]+=1
		for i in range(0,101):
			if d[i]!=0:
				d[i]-=1
			else:
				ans+=i
				break
		for i,v in d.items():
			if v==0:
				print(ans+i)
				break

# region fastio
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")

# endregion

if __name__=="__main__":
	main()


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-7):
	""" Locate the first value x s.t. func(x) = True within [lo, hi] """
	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-7):
	""" Find maximum of unimodal function func() within [lo, hi] """
	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):
	""" Locate the first value x s.t. func(x) = True within [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):
	""" Find the first maximum of unimodal function func() within [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
		#Relax all the neighbours of u
		for t in E[u]:
			v,r=t
			if dist[v]>d+r:
				dist[v]=d+r
				hq.heappush(queue,(dist[v],v))
		#Node u has been processed
		visited.add(u)
	return dist

def prime_sieve(n):
	"""returns a sieve of primes >= 5 and < 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):
	"""returns a list of primes <= 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):
	""" Uses Dijkstra's algortihm to find the shortest path between in a graph. """
	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):
	"""
	finds a shortest path in undirected `graph` between `start` and `goal`.
	If no path is found, returns `None`
	"""
	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  # no path found. not strictly needed

def fillPrefixSum(arr,n,prefixSum):
	prefixSum[0]=arr[0]

	# Adding present element
	# with previous element
	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

'''for _ in range(int(input())):
	n,m=list(map(int,input().split()))
	graph=defaultdict(list)
	distance=[-1]*(n+1)
	visited=[False]*(n+1)
	for _ in range(m):
		x,y=list(map(int,input().split()))
		graph[x].append(y)
		graph[y].append(x)'''
'''for _ in range(int(input())):
	n,m=list(map(int,input().split()))
	graph=[[]for _ in range(n+1)]
	distance=[-1]*(n+1)
	visited=[False]*(n+1)
	for _ in range(m):
		x,y,w=list(map(int,input().split()))
		graph[x].append([y,w])
		graph[y].append([x,w])'''

import os
import sys
from io import BytesIO,IOBase

def DecimalToBinary(n):
	def helper(n):
		if n==0:
			return ''  # <- empty string
		else:
			if n%2==1:
				binaryDigit='1'
			else:
				binaryDigit='0'
			return helper(n//2)+binaryDigit

	if n==0:
		result='0'  # <- "leading zero" only for `n == 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):
	# Sort the array
	arr.sort()

	# find the max frequency using
	# linear traversal
	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 last element is most frequent
	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]

	# returns the length of the LDS
	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)

# region fastio
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")

# endregion

if __name__=="__main__":
	main()


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-7):
	""" Locate the first value x s.t. func(x) = True within [lo, hi] """
	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-7):
	""" Find maximum of unimodal function func() within [lo, hi] """
	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):
	""" Locate the first value x s.t. func(x) = True within [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):
	""" Find the first maximum of unimodal function func() within [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
		#Relax all the neighbours of u
		for t in E[u]:
			v,r=t
			if dist[v]>d+r:
				dist[v]=d+r
				hq.heappush(queue,(dist[v],v))
		#Node u has been processed
		visited.add(u)
	return dist

def prime_sieve(n):
	"""returns a sieve of primes >= 5 and < 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):
	"""returns a list of primes <= 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):
	""" Uses Dijkstra's algortihm to find the shortest path between in a graph. """
	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):
	"""
	finds a shortest path in undirected `graph` between `start` and `goal`.
	If no path is found, returns `None`
	"""
	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  # no path found. not strictly needed

def fillPrefixSum(arr,n,prefixSum):
	prefixSum[0]=arr[0]

	# Adding present element
	# with previous element
	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

'''for _ in range(int(input())):
	n,m=list(map(int,input().split()))
	graph=defaultdict(list)
	distance=[-1]*(n+1)
	visited=[False]*(n+1)
	for _ in range(m):
		x,y=list(map(int,input().split()))
		graph[x].append(y)
		graph[y].append(x)'''
'''for _ in range(int(input())):
	n,m=list(map(int,input().split()))
	graph=[[]for _ in range(n+1)]
	distance=[-1]*(n+1)
	visited=[False]*(n+1)
	for _ in range(m):
		x,y,w=list(map(int,input().split()))
		graph[x].append([y,w])
		graph[y].append([x,w])'''

import os
import sys
from io import BytesIO,IOBase

def DecimalToBinary(n):
	def helper(n):
		if n==0:
			return ''  # <- empty string
		else:
			if n%2==1:
				binaryDigit='1'
			else:
				binaryDigit='0'
			return helper(n//2)+binaryDigit

	if n==0:
		result='0'  # <- "leading zero" only for `n == 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):
	# Sort the array
	arr.sort()

	# find the max frequency using
	# linear traversal
	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 last element is most frequent
	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]

	# returns the length of the LDS
	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()
		d={}
		ans=0
		for i in range(0,100):
			d[i]=0
		for i in a:
			d[i]+=1
		for i in range(0,100):
			if d[i]!=0:
				d[i]-=1
			else:
				ans+=i
				break
		for i,v in d.items():
			if v==0:
				print(ans+i)
				break

# region fastio
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")

# endregion

if __name__=="__main__":
	main()


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()))
    l.sort()
    s = list(dict.fromkeys(l))

    x = 0

    while(x in s):
        x += 1
    res = x
    x = -1
    c = Counter(l)
    for i in range(n):
        if(c[l[i]]==1):
            x = l[i]
            break
    if res != 0:
        if x == -1:
            for i in range(101):
                if c[i]>=2:
                    res += 1
            return res
        else:
            print(res+x)
    else:
        print(0)

for _ in range(int(input())):
    print(solve())


import sys, os.path
import math
from collections import Counter
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()))
    l.sort()
    s = set(l)
    x = 0
    while(x in s):
        x += 1
    res = x
    x = -1
    c = Counter(l)
    if c[0] == n:
        return 2
    else:
        for i in range(n):
            if c[l[i]] == 1:
                x = l[i]
                break
        if res == 0:
            return 0
        if (x == -1):
            return res
        else:
            return res + x

for _ in range(int(input())):
    print(solve())


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())


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()))
    l.sort()
    s = list(dict.fromkeys(l))

    x = 0

    while(x in s):
        x += 1
    res = x
    x = -1
    c = Counter(l)
    for i in range(n):
        if(c[l[i]]==1):
            x = l[i]
            break
    if res != 0:
        if x == -1:
            for i in range(101):
                if c[i]>=2:
                    res += 1
            return res
        else:
            return res + x
    else:
        return 0

for _ in range(int(input())):
    print(solve())


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()))
    l.sort()
    s = list(dict.fromkeys(l))

    x = 0

    while(x in s):
        x += 1
    res = x
    x = -1
    c = Counter(l)
    for i in range(n):
        if(c[l[i]]==1):
            x = l[i]
            break
    if res != 0:
        if x == -1:
            for i in range(101):
                if c[i]>=2:
                    res += 1
            print(res)
        else:
            print(res+x)
    else:
        print(0)

for _ in range(int(input())):
    print(solve())


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()))
    l.sort()
    s = list(dict.fromkeys(l))

    x = 0

    while(x in s):
        x += 1
    res = x
    x = -1
    c = Counter(l)
    for i in range(n):
        if(c[l[i]]==1):
            x = l[i]
            break
    if res != 0:
        if x == -1:
            for i in range(101):
                if c[i]>=2:
                    res += 1
        return res
        else:
            print(res+x)
    else:
        print(0)

for _ in range(int(input())):
    print(solve())


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)


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(100):
        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)


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
    for i in range(100):
        if cnt[i] == 2:
            continue
        if cnt[i] == 1:
            if num1 == -1:
                num1 = i
        if cnt[i] == 0:
            if num1 != -1:
                num2 = i
            else:
                num1 = num2 = i
        if num1 != -1 and num2 != -1:
            break
    print(num1 + num2)


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
    for i in range(101):
        if cnt[i] == 2:
            continue
        if cnt[i] == 1:
            if num1 == -1:
                num1 = i
        if cnt[i] == 0:
            if num1 != -1:
                num2 = i
            else:
                num1 = num2 = i
        if num1 != -1 and num2 != -1:
            break
    print(num1 + num2)


# Fast IO (be careful about bytestring, not on interactive)

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)


# Fast IO (be careful about bytestring, not on interactive)

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 = 0
    oneMax = 0
    for i in range(101):
        if elemCount[i] == 0:
            break
        if elemCount[i] == 1:
            oneMax = i
        if elemCount[i] == 2:
            oneMax = i
            twoMax = i
    print(oneMax + twoMax)


# Fast IO (be careful about bytestring, not on interactive)

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
    oneMax = -1
    for i in range(101):
        if elemCount[i] == 0:
            break
        if elemCount[i] == 1:
            oneMax = i
        if elemCount[i] == 2:
            oneMax = i
            twoMax = i
    print(oneMax + 1 + twoMax + 1)


# Fast IO (be careful about bytestring, not on interactive)

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 not twoMaxEnd:
            oneMax = i
            twoMax = i
    print(oneMax + 1 + twoMax + 1)


# Fast IO (be careful about bytestring, not on interactive)

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 not twoMaxEnd:
            oneMax = i
            twoMax = i
    print(oneMax + 1 + twoMax + 1)


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 zi<oi:
        print(2*zi)
    else:
        print(zi+oi)


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)


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)
    if zi<oi:
        print(2*zi)
    else:
        print(zi+oi)


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pii;
typedef vector<int>vi;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define fi first
#define se second
#define de(x) cout<<#x<<"="<<x<<"\n"
#define dd(x) cout<<#x<<"="<<x<<" "
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define lowbit(a) ((a)&-(a))
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
const int N=2e6+5;
vi ans;
bool vis[N];
namespace DCC{
    const int N = 202020;
    vi key , dcc[N];
    vi e;
    int dfn[N] , low[N] , st[N] , _st , _;
    void dfs(int c,int fa,int dep,const vector<pii> g[]){
  //  	dd("visit"),de(c);
		int cc=0,out=1<dep;st[_st++]=c;
        dfn[c]=low[c]=dep;
        for(auto it:g[c]){
        	int t = it.fi;
        	if(vis[it.se])continue;
        	vis[it.se] = true;
            if(!dfn[t]){
            	e.pb(it.se);
                dfs(t,c,dep+1,g);
                low[c]=min(low[c],low[t]);
                if(low[t]>=dfn[c]){
                    if(++out==2) key.pb(c);
                    vi tmp;
					while(e.back()!=it.se){
                    	tmp.pb(e.back());
                    	e.pop_back();
					}
					tmp.pb(e.back()),e.pop_back();
					int cnt = 2;
                    while(st[--_st]!=t) dcc[st[_st]].pb(_),cnt++;
                    dcc[c].pb(_);dcc[t].pb(_++);
                	if(sz(tmp) == cnt){
                		for(auto x:tmp){
                			ans.pb(x);
						}
					}
					tmp.clear();
				}
            } else {
                low[c] = min(low[c] , dfn[t]);
				e.pb(it.se);
            }
        }
    }
    int solve(int n,const vector<pii> g[]){// n is size of points
        fill_n(dfn,n,_=0);
        fill_n(low,n,_st=0);
        fill_n(dcc,n,key=vi());
        rep(i,0,n) if(!dfn[i]) dfs(i,-1,1,g);
        rep(i,0,n) if(sz(dcc[i]) == 0) dcc[i].pb(_++);
        return _;
    }
}
vector<pii> g[N],ng[N];
int n,m;
int main()
{
	cin>>n>>m;
	rep( i , 0 , m ){
		int u,v;
		cin>>u>>v;
		u--,v--;
		g[u].pb(pii(v,i)),g[v].pb(pii(u,i));
	}
	DCC::solve(n,g);
	cout<<sz(ans)<<"\n";
	sort(all(ans));
	for(auto x:ans)
		cout<<x+1<<" ";

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pii;
typedef vector<int>vi;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define fi first
#define se second
#define de(x) cout<<#x<<"="<<x<<"\n"
#define dd(x) cout<<#x<<"="<<x<<" "
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define lowbit(a) ((a)&-(a))
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
const int N=2e6+5;
vi ans;
bool vis[N];
namespace DCC{
    const int N = 202020;
    vi key , dcc[N];
    vi e;
    int dfn[N] , low[N] , st[N] , _st , _;
    void dfs(int c,int fa,int dep,const vector<pii> g[]){
  //  	dd("visit"),de(c);
		int cc=0,out=1<dep;st[_st++]=c;
        dfn[c]=low[c]=dep;
        for(auto it:g[c]){
        	int t = it.fi;
        	if(vis[it.se])continue;
        	vis[it.se] = true;

            if(!dfn[t]){
            	e.pb(it.se);
                dfs(t,c,dep+1,g);
                low[c]=min(low[c],low[t]);
                if(low[t]>=dfn[c]){
                    if(++out==2) key.pb(c);
                    vi tmp;
					while(e.back()!=it.se){
                    	tmp.pb(e.back());
                    	e.pop_back();
					}
					tmp.pb(e.back()),e.pop_back();
					int cnt = 2;
             /*      dd(t),dd(low[t]),de(c);
					de(cnt);
                    de(sz(tmp));*/
                    while(st[--_st]!=t) dcc[st[_st]].pb(_),cnt++;
                    dcc[c].pb(_);dcc[t].pb(_++);
                	if(sz(tmp) == cnt){
                		for(auto x:tmp){
                			ans.pb(x);
						}
					}
					tmp.clear();
				}
            } else if(dfn[t] != dfn[c] - 1 || cc++){
                low[c] = min(low[c] , dfn[t]);
				e.pb(it.se);
            }
        }
    }
    int solve(int n,const vector<pii> g[]){// n is size of points
        fill_n(dfn,n,_=0);
        fill_n(low,n,_st=0);
        fill_n(dcc,n,key=vi());
        rep(i,0,n) if(!dfn[i]) dfs(i,-1,1,g);
        rep(i,0,n) if(sz(dcc[i]) == 0) dcc[i].pb(_++);
        return _;
    }
}
vector<pii> g[N],ng[N];
int n,m;
int main()
{
	cin>>n>>m;
	rep( i , 0 , m ){
		int u,v;
		cin>>u>>v;
		u--,v--;
		g[u].pb(pii(v,i)),g[v].pb(pii(u,i));
	}
	DCC::solve(n,g);
	cout<<sz(ans)<<"\n";
	sort(all(ans));
	for(auto x:ans)
		cout<<x+1<<" ";

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,int>pii;
typedef vector<int>vi;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define fi first
#define se second
#define de(x) cout<<#x<<"="<<x<<"\n"
#define dd(x) cout<<#x<<"="<<x<<" "
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define lowbit(a) ((a)&-(a))
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
const int N=2e6+5;
// tmp -> the set of edge of the ith connected component
// by tagging edge   vis[];
vi ans;
namespace DCC{
    const int N = 202020;
    vi key , dcc[N],e_st[N];
    vi e;
    int dfn[N] , low[N] , st[N] , _st , _;
    bool vis[N];
    void dfs(int c,int fa,int dep,const vector<pii> g[]){
		int cc=0,out=1<dep;st[_st++]=c;
        dfn[c]=low[c]=dep;
        for(auto it:g[c]){
        	int t = it.fi;
        	if(vis[it.se])continue;
			vis[it.se] = true;
            if(!dfn[t]){
            	e.pb(it.se);
                dfs(t,c,dep+1,g);
                low[c]=min(low[c],low[t]);
                if(low[t]>=dfn[c]){
                    if(++out==2) key.pb(c);
					while(e.back()!=it.se){
                    	e_st[_].pb(e.back());
                    	e.pop_back();
					}
					e_st[_].pb(e.back()),e.pop_back();
					int cnt = 2;
                    while(st[--_st]!=t) dcc[st[_st]].pb(_),cnt++;
                    dcc[c].pb(_);dcc[t].pb(_++);
                    if(sz(e_st[_-1]) == cnt){
                		for(auto x:e_st[_-1]){
                			ans.pb(x);
						}
					}

				}
            } else if(dfn[t] != dfn[c] - 1 || cc++){
                low[c] = min(low[c] , dfn[t]);
				e.pb(it.se);
            }
        }
    }
    int solve(int n,const vector<pii> g[]){// n is size of points
        fill_n(dfn,n,_=0);
        fill_n(low,n,_st=0);
        fill_n(dcc,n,key=vi());
        rep(i,0,n) if(!dfn[i]) dfs(i,-1,1,g);
        rep(i,0,n) if(sz(dcc[i]) == 0) dcc[i].pb(_++);
        return _;
    }
}

vector<pii> g[N],ng[N];
int n,m;
int main()
{
	cin>>n>>m;
	rep( i , 0 , m ){
		int u,v;
		cin>>u>>v;
		u--,v--;
		g[u].pb(pii(v,i)),g[v].pb(pii(u,i));
	}
	DCC::solve(n,g);
	cout<<sz(ans)<<"\n";
	sort(all(ans));
	for(auto x:ans)
		cout<<x+1<<" ";

	return 0;
}