description: Paprika loves permutations. She has an array a_1, a_2, ..., a_n. She wants to make the array a permutation of integers 1 to n.
  
  In order to achieve this goal, she can perform operations on the array. In each operation she can choose two integers i (1 ≤ i ≤ n) and x (x > 0), then perform a_i := a_i mod x (that is, replace a_i by the remainder of a_i divided by x). In different operations, the chosen i and x can be different.
  
  Determine the minimum number of operations needed to make the array a permutation of integers 1 to n. If it is impossible, output -1.
  
  A permutation is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array) and [1,3,4] is also not a permutation (n=3 but there is 4 in the array).
  
  Input
  
  Each test contains multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. Description of the test cases follows.
  
  The first line of each test case contains an integer n (1 ≤ n ≤ 10^5).
  
  The second line of each test case contains n integers a_1, a_2, ..., a_n. (1 ≤ a_i ≤ 10^9).
  
  It is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.
  
  Output
  
  For each test case, output the minimum number of operations needed to make the array a permutation of integers 1 to n, or -1 if it is impossible.
  
  Example
  
  Input
  
  
  4
  2
  1 7
  3
  1 5 4
  4
  12345678 87654321 20211218 23571113
  9
  1 2 3 4 18 19 5 6 7
  
  
  Output
  
  
  1
  -1
  4
  2
  
  Note
  
  For the first test, the only possible sequence of operations which minimizes the number of operations is: 
  
    * Choose i=2, x=5. Perform a_2 := a_2 mod 5 = 2. 
  
  
  
  For the second test, it is impossible to obtain a permutation of integers from 1 to n.
solution: #include <bits/stdc++.h>
  using namespace std;
  template <class T>
  void _R(T &x) {
    cin >> x;
  }
  void _R(int &x) { scanf("%d", &x); }
  void _R(long long &x) { scanf("%lld", &x); }
  void _R(unsigned long long &x) { scanf("%llu", &x); }
  void _R(double &x) { scanf("%lf", &x); }
  void _R(char &x) { scanf(" %c", &x); }
  void _R(char *x) { scanf("%s", x); }
  void R() {}
  template <class T, class... U>
  void R(T &head, U &...tail) {
    _R(head);
    R(tail...);
  }
  template <class T>
  void _W(const T &x) {
    cout << x;
  }
  void _W(const int &x) { printf("%d", x); }
  void _W(const long long &x) { printf("%lld", x); }
  void _W(const double &x) { printf("%.16f", x); }
  void _W(const char &x) { putchar(x); }
  void _W(const char *x) { printf("%s", x); }
  template <class T, class U>
  void _W(const pair<T, U> &x) {
    _W(x.first);
    putchar(' ');
    _W(x.second);
  }
  template <class T>
  void _W(const vector<T> &x) {
    for (auto i = x.begin(); i != x.end(); _W(*i++))
      if (i != x.cbegin()) putchar(' ');
  }
  void W() {}
  template <class T, class... U>
  void W(const T &head, const U &...tail) {
    _W(head);
    putchar(sizeof...(tail) ? ' ' : '\n');
    W(tail...);
  }
  const int MOD = 1e9 + 7, mod = 998244353;
  long long qpow(long long a, long long b) {
    long long res = 1;
    a %= MOD;
    assert(b >= 0);
    for (; b; b >>= 1) {
      if (b & 1) res = res * a % MOD;
      a = a * a % MOD;
    }
    return res;
  }
  const int MAXN = 4e5 + 10, MAXM = 1e7 + 10;
  const int INF = INT_MAX, SINF = 0x3f3f3f3f;
  const long long llINF = LLONG_MAX;
  const int inv2 = (MOD + 1) / 2;
  const int Lim = 1 << 20;
  int a[MAXN];
  int n;
  int cnt[MAXN];
  void solve() {
    R(n);
    memset(cnt, 0, (n + 6) * sizeof(int));
    for (int i = 1; i <= n; i++) R(a[i]);
    vector<int> vec;
    for (int i = 1; i <= n; i++) {
      if (a[i] <= n && !cnt[a[i]])
        cnt[a[i]] = 1;
      else
        vec.push_back(a[i]);
    }
    sort((vec).begin(), (vec).end());
    reverse((vec).begin(), (vec).end());
    int c = 0;
    for (int i = 1; i <= n; i++)
      if (!cnt[i]) {
        c++;
        int p = vec.back();
        vec.pop_back();
        int q = i;
        if (p - q <= q) return W(-1);
      }
    W(c);
  }
  int main() {
    int T = 1;
    scanf("%d", &T);
    for (int kase = 1; kase <= T; kase++) {
      solve();
    }
    return 0;
  }
  