use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::io::BufRead;
fn solve(my: Vec<usize>) -> usize {
let n = my.len() * 2;
let my: BTreeSet<_> = my.into_iter().collect();
let mut other = VecDeque::new();
for i in 1..=n {
if !my.contains(&i) {
other.push_front(i);
}
}
let mut my: VecDeque<_> = my.into_iter().collect();
let mut points = 0;
for o in other {
if *my.back().unwrap() > o {
my.pop_back();
points += 1;
} else {
my.pop_front();
}
}
points
}
fn main() {
let stdin = std::io::stdin();
let stdin = stdin.lock();
let mut lines = stdin.lines();
let t: usize = lines.next().unwrap().unwrap().parse().unwrap();
for _ in 0..t {
let n: usize = lines.next().unwrap().unwrap().parse().unwrap();
let v = lines
.next()
.unwrap()
.unwrap()
.split_whitespace()
.map(|v| v.parse().unwrap())
.collect();
println!("{}", solve(v));
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_samples() {
assert_eq!(solve(vec![2, 4, 5]), 2);
assert_eq!(solve(vec![1]), 0);
assert_eq!(solve(vec![1, 3]), 1);
}
}