#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


int main()
{
	#ifndef ONLINE_JUDGE
	freopen("/home/naman/Desktop/input.txt","r",stdin);
	freopen("/home/naman/Desktop/output.txt","w",stdout);
	#endif

	IOS;
	
	int t;
	cin>>t;

	while(t--)
	{
		int n;
		cin>>n;
		unordered_map<int,int>m1;
		int fl[n+2];
		memset(fl,0,sizeof(fl));

		int b[n];
		vector<int>c;
		for (int i = 0; i < n; ++i)
		{
			cin>>b[i];
			m1[b[i]]=1;
		}
		for (int i = 0; i < 2*n; ++i)
		{
			if(!m1.count(i+1))
				c.pb(i+1);
		}

		for(int i=0;i<n;i++)
		{
			// x>=i+1
			// n-x+i
			// x<=k
			int l,r;
			l=i+1;
			r=n;
			while(r>l)
			{
				int mid = (r+l+1)/2;
				if(b[i]<c[n-mid+i])
				{
					l=mid;
				}
				else
					r=mid-1;
			}
			if(c[n-l+i]>b[i])
			{
				fl[i+1]++;
				fl[l+1]--;
			}

			// x<=i
			// i-x->i
			l=0;
			r=i;
			while(r>l)
			{
				int mid = (r+l)/2;
				if(c[i-mid]<b[i])
				{
					r=mid;
				}
				else
					l=mid+1;
			}
			if(c[i-l]<b[i])
			{
				fl[l]++;
				fl[i+1]--;
			}
		}
		for(int i=1;i<=n;i++)
		{
			fl[i]+=fl[i-1];
		}
		int ans=0;
		for(int i=0;i<=n;i++)
		{
			if(fl[i]==n)
				ans++;
		}
		cout<<ans<<"\n";

	}
	

}