#include <bits/stdc++.h>
using namespace std;


int calc_mex(vector<int> & v)
{
  int ans = v.size();
  int n = v.size();
  for (int i = 0; i < n; i++)
  {
    if (v[i] != i)
      return i;
  }
  return ans;
}

void mainSolve()
{
  int n;
  cin >> n;
  set<int> s;
  for (int i = 0; i < n; i++)
  {
    int x;
    cin >> x;
    s.insert(x);
  }
  vector<int> v;
  for (int x : s)
    v.push_back(x);
  int mex = calc_mex(v);
  if (mex == 0)
  {
    cout << (v[0] - 1) << endl;
    return;
  }
  if (mex == 1)
  {
    cout << -1 << endl;
    return;
  }
  int ans = 0;
  n = v.size();
  for (int i = 0; i < n;)
  {
    int cnt = 1;
    int j = i + 1;
    while (j < n && v[j] - v[j - 1] == 1)
      ++cnt, j++;
    if (cnt >= (mex - 1))
      ++ans;
    i = j;
  }
  --ans;
  cout << ans << endl;
}

int main()
{
  int t;
  cin >> t;
  while (t--)
  {
    mainSolve();
  }
  return 0;
}