#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define mod 1000000007
using namespace std;
void solve()
{
ll n, i, mex=0;
cin>> n;
ll a[n+5], sum=0;
vector <ll> v;
map <ll, ll> cnt;
for(i=0; i<n; i++)
{
cin>> a[i];
cnt[a[i]]++;
if(cnt[a[i]]==1) v.pb(a[i]);
else sum+=a[i];
}
sort(v.begin(), v.end());
for(i=0; i<v.size(); i++)
{
if(mex==v[i]) mex++;
else if(sum>=mex)
{
sum = sum-mex;
mex++;
i--;
}
}
while(sum>0)
{
if(sum>=mex)
{
sum = sum-mex;
mex++;
i--;
}
else break;
}
cout<< mex << '\n';
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll T = 1, cs = 1, i, k=0;
cin >> T;
//sieve();
//cin.get();
while(T--)
{
//cout<< "Case " << cs++ << ": ";
solve();
}
return 0;
}