#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)

bool poss(int a[],int minn[],int maxx[],int x,int n) {
    if(x==0) {
        if(maxx[0]==1) return true;
        else return false;
    } else if(x==n) {
        if(minn[n-1]==1) return true;
        else return false;
    } else {
        if(minn[x-1]==1 && maxx[x]==1) return true;
        else return false;
    }
}

int32_t main() {
    int t;cin>>t;
    while(t--) {
        int n;cin>>n;
        int a[n];
        rep(i,n)cin>>a[i];
        sort(a,a+n);
        int maxx[n];int minn[n];
        int tot = 2*n-a[0]-n+1;int rem=0;
        for(int i=0;i<n;i++) {
            if(tot>0) minn[i]=1;
            else {
                minn[i]=0;
                for(int i1=i+1;i1<n;i1++)minn[i1]=0;
                break;
            }
            rem++;
            if(i==n-1)break;
            tot--;
            tot-=(a[i+1]-a[i]-1);
            int rem1 = max(0LL,rem-(a[i+1]-a[i]-1));
            tot = tot+rem-rem1;
            rem=rem1;
        }
        tot = a[n-1]-1-n+1;rem=0;
        for(int i=n-1;i>=0;i--) {
            if(tot>0) maxx[i]=1;
            else {
                maxx[i]=0;
                for(int i1=i-1;i1>=0;i1--)maxx[i1]=0;
                break;
            }
            rem++;
            if(i==0)break;
            tot--;
            tot-=(a[i]-a[i-1]-1);
            int rem1 = max(0LL,rem-(a[i]-a[i-1]-1));
            tot = tot+rem-rem1;
            rem=rem1;
        }
        int ans=0;
        f(i,0,n) {
            if(poss(a,minn,maxx,i,n)){ans++;}
        }
        cout<<ans<<endl;
    }
}
