#include <iostream>
#include <set>
using namespace std;
int main()
{
int t;
cin >> t;
for (int i = 0; i < t; ++i) {
int n;
cin >> n;
set<int> my_c;
for (int a = 0; a < n / 2; ++a) {
int c;
cin >> c;
my_c.insert(c);
}
set<int> opp_c;
for (int a = 0; a < n; ++a) {
if (my_c.find(a + 1) == my_c.end()) {
opp_c.insert(a + 1);
}
}
int w = 0;
for (auto it = opp_c.rbegin(); it != opp_c.rend(); ++it) {
auto beat = my_c.upper_bound(*it);
if (beat != my_c.end()) {
++w;
my_c.erase(beat);
} else {
my_c.erase(my_c.begin());
}
}
cout << w << endl;
}
}