#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int t; // testit
int main() {
cin >> t;
for (int i = 0; i < t; i++) {
int n; // korttien määrä
cin >> n;
vector<int> pakka1;
pakka1.resize(n / 2);
for (int i = 0; i < n / 2; i++) cin >> pakka1[i];
sort(pakka1.begin(), pakka1.end());
vector<int> pakka2;
for (int i = 1, ii = 0; i <= n; i++) {
if (i == pakka1[ii]) {
ii++;
continue;
}
pakka2.push_back(i);
}
/*
cout << "Pakka 1\n";
for (auto i : pakka1) {
cout << i << " ";
}
cout << "\n\n";
cout << "Pakka 2\n";
for (auto i : pakka2) {
cout << i << " ";
}
cout << "\n\n";
*/
int points = 0;
for (int i = n / 2 - 1; i >= 0; i--) {
if (pakka1[i] > pakka2[i]) {
points++;
pakka1.pop_back();
} else {
pakka1.erase(pakka1.begin());
}
}
cout << points << "\n";
}
}