#include <iostream>
#include <cstring>
using namespace std;
int f[1000001];
int solve (int a[], int n) {
for (int i=0; i<n; i++) {
if (a[i]>=0 && !f[a[i]]) {
f[a[i]]=1;
}
}
for (int i=1; i<1000000; i++) {
if (!f[i]) return i;
}
return -1;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t; cin >> t;
while (t--) {
memset (f, sizeof(f), 0);
int n; cin >> n;
int a[n];
for (int i=0; i<n; i++) cin >> a[i];
cout << solve (a, n) << endl;
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0cmluZz4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IGZbMTAwMDAwMV07CgppbnQgc29sdmUgKGludCBhW10sIGludCBuKSB7Cglmb3IgKGludCBpPTA7IGk8bjsgaSsrKSB7CgkJaWYgKGFbaV0+PTAgJiYgIWZbYVtpXV0pIHsKCQkJZlthW2ldXT0xOwoJCX0gCgl9Cglmb3IgKGludCBpPTE7IGk8MTAwMDAwMDsgaSsrKSB7CgkJaWYgKCFmW2ldKSByZXR1cm4gaTsgCgl9CglyZXR1cm4gLTE7Cn0KIAppbnQgbWFpbigpIHsKICAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpOwogICAgY2luLnRpZShudWxscHRyKTsKICAgIAogICAgaW50IHQ7IGNpbiA+PiB0OwogICAgd2hpbGUgKHQtLSkgewogICAgCW1lbXNldCAoZiwgc2l6ZW9mKGYpLCAwKTsKCSAgICBpbnQgbjsgY2luID4+IG47CgkgICAgaW50IGFbbl07IAoJICAgIGZvciAoaW50IGk9MDsgaTxuOyBpKyspIGNpbiA+PiBhW2ldOyAKCQljb3V0IDw8IHNvbHZlIChhLCBuKSA8PCBlbmRsOwoJfQp9