#include <bits/stdc++.h>
using namespace std;
priority_queue<long long int, vector<long long int>, greater<long long int> >
    ti;
vector<long long int> r[300005], y[300005], b(300005, 0), f(2000005, 0);
long long int vis[200005];
map<pair<long long int, long long int>, long long int> mp;
set<pair<long long int, long long int> > s;
set<long long int> st;
map<long long int, long long int> np, v;
queue<long long int> qy;
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int bpow(long long int a, long long int b) {
  long long int res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % 998244353;
    a = (a * a) % 998244353;
    b >>= 1;
  }
  return res % 998244353;
}
long long int fact(long long int i) {
  f[0] = 1;
  for (long long int k = 1; k <= i; k++) {
    (f[k] = f[k - 1] * k) %= 998244353;
  }
  return f[i];
}
long long int isprime(long long int n) {
  if (n == 1) return 0;
  for (long long int i = 2; i <= sqrt(n); i++)
    if (n % i == 0) return 0;
  return 1;
}
vector<long long int> p, q;
void add() {
  long long int k = p.size();
  vector<long long int> f;
  for (long long int i = 0; i < k; i++) {
    q.push_back(p[i]);
    long long int j = 0;
    while (j < f.size()) {
      q.push_back(f[j]);
      j++;
    }
    f = q;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    vector<long long int> a(n);
    map<long long int, long long int> mp;
    for (long long int i = 0; i < n; i++) {
      cin >> a[i];
      mp[a[i]]++;
    }
    long long int c1 = 0, c2 = 0;
    long long int f = 0;
    for (long long int i = 0; i < n; i++) {
      if (mp[i] >= 1) {
        c1++;
        if (mp[i] == 1) f = 1;
      }
      if (mp[i] > 1 && f == 0) {
        c2++;
      }
      if (mp[i] == 0) {
        break;
      }
    }
    cout << c1 + c2 << "\n";
  }
}
