#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[10000];
bool seen[10000];
void testCase() {
int n;
cin >> n;
for (int i = 0; i < n/2; i++) cin >> a[i];
for (int i = 0; i <= n; i++) seen[i] = false;
for (int i = 0; i < n/2; i++) seen[a[i]] = true;
vector<int> v;
for (int i = 1; i <= n; i++) {
if (!seen[i]) v.push_back(i);
}
sort(v.rbegin(), v.rend());
sort(a,a+(n/2));
int ans = 0;
int j = n/2-1;
for (int x : v) {
if (a[j] > x) {
ans++;
j--;
}
}
cout << ans << "\n";
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
for (int i = 0; i < t; i++) {
testCase();
}
}