#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>

#define LL long long

using namespace std;

inline int read(void)
{
	int sum=0;int sign=1;char ch=getchar();
	while(ch>'9'||ch<'0') {if(ch=='-') sign=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') {sum=sum*10+ch-'0';ch=getchar();}
	return sum*sign;
}

int T;
int n;
int a[500010];
int b[500010];

LL jie(int x)
{
	LL res=1;
	for(int i=1;i<=x;i++)
	{
		res*=1ll*i;
	}
	return res;
}

int main()
{
	cin>>T;
	while(T--)
	{
		cin>>n;
		LL ans=0;
		for(int i=1;i<=n;i++)
		{
			cin>>b[i];
			int x=b[i]-i+n;
			a[x]++;
		}
		for(int i=1;i<=2*n;i++)
		{
			if(a[i]>=2)
			ans+=1ll*a[i]*(a[i]-1)/2;
		}
		printf("%lld\n",ans);
		for(int i=1;i<=n;i++)
		{
			int x=b[i]-i+n;
			a[x]--;
		}
	}
	return 0;
}
