#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
size_t choose_card(int other, std::vector<int> own_cards) {
auto it = std::upper_bound(
own_cards.begin(),
own_cards.end(),
other
);
if (it != own_cards.end()) {
return it - own_cards.begin();
} else {
return 0;
}
}
std::vector<int> missing_cards(std::vector<int> cards) {
int n = cards.size() * 2;
size_t pos = 0;
std::vector<int> other_cards;
other_cards.reserve(n / 2);
for (int i = 1; i <= n; ++i) {
if (i != cards[pos]) {
other_cards.push_back(i);
} else {
++pos;
}
}
return other_cards;
}
std::vector<int> read_cards(int count) {
std::vector<int> cards(count);
for (int i = 0; i < count; ++i) {
std::cin >> cards[i];
//std::cerr << cards[i] << " ";
}
//std::cerr << std::endl;
std::sort(cards.begin(), cards.end());
return cards;
}
void perform_test() {
int n = 0;
int score = 0;
std::cin >> n;
std::vector<int> own_cards = read_cards(n / 2);
std::vector<int> other_cards = missing_cards(own_cards);
for (auto it = other_cards.rbegin(); it != other_cards.rend(); ++it) {
int other_card = *it;
//std::cerr << "<" << other_card << std::endl;
size_t card_i = choose_card(other_card, own_cards);
assert(card_i < own_cards.size());
int card = own_cards[card_i];
//std::cerr << ">" << card << std::endl;
own_cards.erase(own_cards.begin() + card_i);
if (card > other_card) {
++score;
}
}
std::cout << score << std::endl;
}
int main() {
int t = 0;
std::cin >> t;
for (int i = 0; i < t; ++i) {
perform_test();
}
}