#include <iostream>
#include <vector>
using namespace std;
int main() {
int tt;
cin>>tt;
for(int xx = 0; xx < tt; ++xx) {
int is_my_card[101] = {0};
int n;
cin>>n;
for(int i = 0; i < n/2; ++i) {
int a;
cin>>a;
is_my_card[a] = 1;
}
std::vector<int> my_cards;
std::vector<int> opponent_cards;
for(int i = 1; i <= n; ++i) {
if(is_my_card[i]) {
my_cards.push_back(i);
}
else {
opponent_cards.push_back(i);
}
}
size_t opponent_pos = 0;
int ans = 0;
for(size_t i = 0; i < my_cards.size(); ++i) {
if(opponent_pos < opponent_cards.size()
&& opponent_cards[opponent_pos] < my_cards[i]) {
++ans;
++opponent_pos;
}
}
cout<<ans<<endl;
}
}