#include <bits/stdc++.h>
typedef long long ll;
#define M 1000000007
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
for (int i = 0; i < t; ++i) {
int n;
cin >> n;
set<int> op;
set<int> me;
for (int i = 1; i <= n; ++i) {
op.insert(i);
}
for (int i = 0; i < n / 2; ++i) {
int val;
cin >> val;
me.insert(val);
op.erase(val);
}
int p = 0;
for (int i = 0; i < n / 2; ++i) {
auto it = op.end();
it--;
int opv = *it;
op.erase(it);
it = me.end();
it--;
int e = *it;
if (e > opv) {
me.erase(it);
p++;
}
else {
me.erase(me.begin());
}
}
cout << p << endl;
}
return 0;
}