/**
* @author: Binoy Barman
* @created: 2024-11-05 20:56:16
**/
#include<bits/stdc++.h>
using namespace std;
#define nl '\n'
#define all(v) v.begin(), v.end()
#define Too_Many_Jobs int tts, tc = 1; cin >> tts; hell: while(tts--)
#define Dark_Lord_Binoy ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifdef LOCAL
#include "debug/whereisit.hpp"
#else
#define dbg(...) 42
#endif
#define int long long
int32_t main() {
Dark_Lord_Binoy
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
Too_Many_Jobs {
int n;
cin >> n;
vector<bool> mex(n + 1, 0);
multiset<int> f;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
f.insert(x);
}
mex[0] = 1;
int l = 1;
while(1) {
if(f.count(l)) {
mex[l] = 1;
f.erase(f.find(l));
l++;
} else {
auto it = f.rbegin();
int cur = 0;
while(it != f.rend()) {
if(cur >= l) break;
cur += *it;
auto k = it;
f.erase(f.find(*it));
it = f.rbegin();
}
if(cur < l) break;
mex[l] = 1;
f.insert(cur - l);
l++;
}
}
cout << l << nl;
}
return 0;
}