#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int N = 111;
bool h[N];
int main() {
iostream::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
for(int i = 1; i <= t; ++i) {
int n;
cin >> n;
vector<int> A;
vector<int> B;
for(int j = 1; j <= n/2; ++j) {
int a;
cin >> a;
A.push_back(a);
h[a] = true;
}
sort(A.begin(), A.end());
for(int j = 1; j <= n; ++j) {
if(!h[j]) {
B.push_back(j);
}
h[j] = false;
}
int sc = 0;
int a = 0;
int b = n/2 - 1;
int k = n/2;
while(k > 0) {
if(A[b] > B[k-1]) {
++sc;
--b;
} else {
++a;
}
--k;
}
cout << sc << "\n";
}
}