#include <bits/stdc++.h>
using namespace std;
const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng(
    (unsigned int)chrono::steady_clock::now().time_since_epoch().count());
const double pi = acos(-1.0);
const long long mod = 1e9 + 7;
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int n;
    scanf("%d", &n);
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
      int w;
      scanf("%d", &w);
      mp[w] += 1;
    }
    int c = 2;
    int ans = 0;
    for (int i = 0; c; i++) {
      if (mp[i] >= c) {
        ans += c;
      } else {
        c = mp[i];
        ans += c;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
