#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n, half;
vector<int> a;
vector<int> b;
void f() {
cin >> n;
half = n/2;
a.clear();
b.clear();
a.resize(half);
for (int i = 0; i < half; i++) cin >> a[i];
sort(a.rbegin(), a.rend());
for (int i = n, ii = 0; i > 0; i--) {
if (i == a[ii]) ii++;
else (b.push_back(i));
}
int points = 0;
int cardsLeft = half;
for (int i = half, ia = 0, ib = 0; i > 0; i--) {
if (a[ia] > b[ib]) {
points++;
ib++;
ia++;
} else {
ib++;
}
}
cout << points << "\n";
}
int t;
int main() {
cin >> t;
for (int i = 0; i < t; i++) f();
}