#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
typedef long long LL;
// Always take smallest that beats the opponent. If does not exist, take smallest in hand.
void solve(){
LL n; cin >> n;
set<LL> have;
for(LL i = 0; i < n/2; i++){
LL x; cin >> x; have.insert(x);
}
set<LL> havenot;
for(LL x = 1; x <= n; x++){
if(have.count(x) == 0) havenot.insert(x);
}
LL ans = 0;
for(LL r = 0; r < n/2; r++){
LL x = *havenot.rbegin(); havenot.erase(x);
auto yi = lower_bound(have.begin(), have.end(), x);
if(yi == have.end()) have.erase(have.begin());
else{
have.erase(yi);
ans++;
}
}
cout << ans << "\n";
}
int main(){
LL t; cin >> t; while(t--) solve();
}