#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
set<int> s;
for (int i = 1; i <= n; ++i) s.insert(i);
vector<int> p(n/2);
for (int i = 0; i < n/2; ++i) {
cin >> p[i];
s.erase(p[i]);
}
vector<int> e;
for (auto c : s) e.push_back(c);
sort(p.rbegin(), p.rend());
sort(e.rbegin(), e.rend());
int a = 0;
int r = 0;
for (int b = 0; b < n/2; ++b) {
if (p[a] > e[b]) {
++r;
++a;
if (a == n/2) break;
}
}
cout << r << '\n';
}
}