t=int(input())
for j in range(0,t):
n=int(input())
a=[0]*n
string=input()
b=string.split(' ')
cnt=[0]*(n+1)
index=0
for i in b:
d=int(i)
a[index]=d
index+=1
cnt[d]+=1
ans=-1
f=0
for i in range(0,n):
if cnt[i]==0:
break
if cnt[i]==1:
if f==1:
break
f=1
ans=i
else:
ans=i
print(ans+1)
1667B - Optimal Partition | 1668B - Social Distance |
88B - Keyboard | 580B - Kefa and Company |
960A - Check the string | 1220A - Cards |
897A - Scarborough Fair | 1433B - Yet Another Bookshelf |
1283B - Candies Division | 1451B - Non-Substring Subsequence |
1408B - Arrays Sum | 1430A - Number of Apartments |
1475A - Odd Divisor | 1454B - Unique Bid Auction |
978C - Letters | 501B - Misha and Changing Handles |
1496A - Split it | 1666L - Labyrinth |
1294B - Collecting Packages | 1642B - Power Walking |
1424M - Ancient Language | 600C - Make Palindrome |
1669D - Colorful Stamp | 1669B - Triple |
1669A - Division | 1669H - Maximal AND |
1669E - 2-Letter Strings | 483A - Counterexample |
3C - Tic-tac-toe | 1669F - Eating Candies |