#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
int n, half;
vector<int> a;
set<int> s;
vector<int> b;
void f() {
cin >> n;
half = n/2;
s.clear();
a.clear();
b.clear();
a.resize(half);
for (int i = 0; i < half; i++) {
int x;
cin >> x;
s.insert(x);
a[i] = x;
}
sort(a.rbegin(), a.rend());
for (int i = n, ii = 0; i > 0; i--) {
if (i == a[ii]) ii++;
else (b.push_back(i));
}
int points = 0;
for (int i = 0; i < half; i++) {
//cout << "finding bigger than: " << b[i] << "\n";
auto it = s.upper_bound(b[i]);
if (it == s.end()) {
//cout << "end" << "\n";
auto iter = s.begin();
//cout << *iter << "\n";
s.erase(iter);
} else {
//cout << *it << "\n";
s.erase(it);
points++;
}
}
cout << points << "\n";
}
int t;
int main() {
cin >> t;
for (int i = 0; i < t; i++) f();
}