You are given an array $a$ of $n$ integers. Count the number of pairs of indices $(i, j)$ such that $i < j$ and $a_j - a_i = j - i$.


-----Input-----

The first line contains one integer $t$ ($1 \le t \le 10^4$). Then $t$ test cases follow.

The first line of each test case contains one integer $n$ ($1 \le n \le 2 \cdot 10^5$).

The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le n$) — array $a$.

It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$.


-----Output-----

For each test case output the number of pairs of indices $(i, j)$ such that $i < j$ and $a_j - a_i = j - i$.


-----Examples-----

Input
4
6
3 5 1 4 6 6
3
1 2 3
4
1 3 3 4
6
1 6 3 4 5 6
Output
1
3
3
10


-----Note-----

None

Source: codeforces | Difficulty: EASY
Tags: String algorithms

Data structures

Mathematics


Solutions:
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	t = []
	for i in range(n):
		t.append(arr[i] - i)
	dic = {}
	for i in range(n):
		if t[i] not in dic:
			dic[t[i]] = 1
		else:
			dic[t[i]] += 1
	count = 0
	for i in dic:
		if dic[i] > 1:
			count += abs(dic[i]) * abs(dic[i] - 1) // (1 + 1)
	print(count)


for i in range(int(input())):
	a = int(input())
	l = list(map(int, input().split()))
	d = {}
	for j in range(a):
		l[j] -= j + 1
	for j in l:
		if j in d:
			d[j] += 1
		else:
			d[j] = 1
	r = 0
	for j in d:
		r += d[j] * (d[j] - 1) // 2
	print(r)


import sys
from collections import Counter
num_cases = int(sys.stdin.readline().strip())
for case in range(1, num_cases + 1):
	N = int(sys.stdin.readline().strip())
	A = sys.stdin.readline().strip().split(' ')
	new_A = []
	for (index, value) in enumerate(A):
		new_A.append(int(value) - index)
	count_A = Counter(new_A).most_common()

	def maker(n):
		return int(n * (n - 1) / 2)
	result = 0
	for (key, value) in count_A:
		if value <= 1:
			break
		else:
			result += maker(value)
	print(result)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	for i in range(n):
		x = a[i] - i
		if x in d:
			d[x] += 1
		else:
			d[x] = 1
	count = 0
	for i in d:
		count += d[i] * (d[i] - 1) // 2
	print(count)


import math
test = int(input())
for t in range(test):
	n = int(input())
	x = list(map(int, input().split()))
	m = {}
	for i in range(n):
		if m.get(x[i] - i):
			m[x[i] - i] += 1
		else:
			m[x[i] - i] = 1
	a = 0
	for i in m.values():
		a += i * (i - 1) // 2
	print(a)


def countPairs(arr, n):
	map = {}
	for i in range(n):
		map[arr[i] - i] = map.get(arr[i] - i, 0) + 1
	res = 0
	for x in map:
		cnt = map[x]
		res += cnt * (cnt - 1) // 2
	return res
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	print(countPairs(l, n))


def fun(A, n):
	d = {}
	for i in range(n):
		if A[i] - i in d:
			c = d[A[i] - i]
			c = c + 1
			d[A[i] - i] = c
		else:
			d[A[i] - i] = 1
	cnt = 0
	for i in d:
		c = d[i]
		cnt = cnt + c * (c - 1) // 2
	return cnt
t = int(input())
for i in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	print(fun(A, n))


t = int(input())
for i in range(t):
	n = int(input())
	nums = list(map(int, input().split()))
	m = {}
	answer = 0
	for i in range(n):
		x = nums[i] - i
		if not x in m:
			m[x] = 1
		else:
			answer += m[x]
			m[x] += 1
	print(answer)


from collections import Counter
for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	for i in range(n):
		l[i] = l[i] - i
	a = Counter(l)
	pairs = 0
	for i in a.values():
		pairs = pairs + i * ((i - 1) / 2)
	print(int(pairs))


from collections import defaultdict
n = int(input())
testcases = []
for i in range(n):
	l = int(input())
	x = list(map(int, input().split()))
	testcases.append(x)

def getPairs(arr):
	freq = defaultdict(int)
	count = 0
	for i in range(len(arr)):
		count += freq[arr[i] - i]
		freq[arr[i] - i] += 1
	return count
for test in testcases:
	print(getPairs(test))


import sys

def findNumPairs(arr):
	count = 0
	equal = {}
	for i in range(len(arr)):
		val = arr[i] - i
		if val not in equal:
			equal[val] = 0
		equal[val] += 1
	for k in equal:
		if equal[k] > 1:
			count += equal[k] * (equal[k] - 1) // 2
	return count
t = int(input())
answer = []
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	answer.append(findNumPairs(arr))
print(*answer, sep='\n')


import sys, heapq, math
from collections import defaultdict
input = sys.stdin.readline
t = int(input())
for i in range(t):
	n = int(input())
	p = defaultdict(int)
	d = list(map(int, input().split()))
	ans = 0
	for j in range(n):
		x = d[j] - j
		ans += p[x]
		p[x] += 1
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.insert(0, 0)
	k = {}
	ans = 0
	for j in range(1, n + 1):
		b = a[j] - j
		if b in k:
			k[b] += 1
		if b not in k:
			k[b] = 1
	for m in k:
		if k[m] > 1:
			ans += k[m] * (k[m] - 1) // 2
	print(int(ans))


from sys import stdin
input = stdin.readline
rn = lambda : int(input())
rns = lambda : map(int, input().split())
rl = lambda : list(map(int, input().split()))
rs = lambda : input()
YN = lambda x: print('YES') if x else print('NO')
mod = 10 ** 9 + 7
from collections import Counter
for _ in range(rn()):
	n = rn()
	a = rl()
	m = min(a)
	for i in range(n):
		a[i] -= m
	b = []
	for i in range(n):
		b.append(a[i] - i)
	c = Counter(b)
	ans = 0
	for i in c:
		ans += c[i] * (c[i] - 1) // 2
	print(ans)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	hmap = {}
	pairs = 0
	for i in range(len(arr)):
		arr[i] -= i
		if arr[i] in hmap:
			hmap[arr[i]] += 1
		else:
			hmap[arr[i]] = 1
	for i in hmap:
		k = hmap[i]
		if k > 1:
			if k == 2:
				pairs += 1
			else:
				pairs += k * (k - 1) // 2
	print(pairs)


from collections import defaultdict as dfd

def solve(n, arr):
	book = dfd(int)
	for i in range(n):
		book[arr[i] - i] += 1
	ans = 0
	for v in book.values():
		if v > 1:
			ans += v * (v - 1) // 2
	return ans
T = int(input())
for case_num in range(1, T + 1):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = solve(n, arr)
	print(f'{ans}')


def main():
	import sys
	t = int(sys.stdin.readline())
	for _ in range(t):
		n = int(sys.stdin.readline())
		s = list(map(int, sys.stdin.readline().split()))
		t = dict()
		c = 0
		for i in range(n):
			r = s[i] - i - 1
			if r in t:
				c += t[r]
			if r in t:
				t[r] += 1
			else:
				t[r] = 1
		sys.stdout.write(str(c) + '\n')
main()


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	d = {}
	ans = 0
	for i in range(n):
		if arr[i] - i in d:
			ans += d[arr[i] - i]
			d[arr[i] - i] += 1
		else:
			d[arr[i] - i] = 1
	print(ans)


def solve(n):
	nums = input().split(' ')
	mem = {}
	out = 0
	for i in range(n):
		num = int(nums[i])
		diff = num - i
		if diff in mem:
			mem[diff] += 1
		else:
			mem[diff] = 1
	for key in mem:
		if mem[key] >= 2:
			out += int(mem[key] * (mem[key] - 1) / 2)
	return out
t = int(input())
for i in range(t):
	n = int(input())
	print(solve(n))


import sys
for _ in range(int(sys.stdin.readline())):
	n = int(sys.stdin.readline().strip())
	s = list(map(int, sys.stdin.readline().strip().split()))
	for i in range(n):
		s[i] -= i + 1
	dic = {}
	for item in s:
		if item not in dic:
			dic[item] = 1
		else:
			dic[item] += 1
	answer = 0
	for item in dic.keys():
		answer += dic[item] * (dic[item] - 1) // 2
	print(answer)


for _ in range(int(input())):
	size = int(input())
	li = list(map(int, input().split()))
	d = {}
	cnt = 0
	for i in range(size):
		var = li[i] - i
		if var not in d:
			d[var] = 1
		else:
			d[var] += 1
	for i in d.values():
		for j in range(1, i):
			cnt += j
	print(cnt)


import heapq
import sys
from collections import *
from heapq import *
import math
import bisect
from itertools import *

def countPairs(arr, n):
	map = dict()
	for i in range(n):
		map[arr[i] - i] = map.get(arr[i] - i, 0) + 1
	res = 0
	for x in map:
		cnt = map[x]
		res += cnt * (cnt - 1) // 2
	return res
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	print(countPairs(arr, n))


def solve():
	dic = {}
	for i in range(n):
		dic[a[i] - i] = dic.get(a[i] - i, 0) + 1
	c = 0
	for val in dic.values():
		c += (val - 1) * val // 2
	return c
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	print(solve())


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	count = 0
	di = dict()
	for i in range(n):
		k = arr[i] - i
		if k in di:
			count += di[k]
			di[k] = di[k] + 1
		else:
			di[k] = 1
	print(count)


from sys import stdin
from math import log, floor, ceil, gcd
from collections import defaultdict as dd
input = stdin.readline
inp = lambda : int(stdin.readline())
rs = lambda : stdin.readline().strip()

def ra(typ):
	return list(map(typ, stdin.readline().split()))

def rv(typ):
	return map(typ, stdin.readline().split())

def main():
	for _ in range(inp()):
		n = inp()
		nums = ra(int)
		ans = dd(int)
		for i in range(1, n + 1):
			x = i - nums[i - 1]
			ans[x] += 1
		c = 0
		for i in ans:
			c += ans[i] * (ans[i] - 1) // 2
		print(c)
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	b = []
	for i in range(n):
		b.append(a[i] - i)
	count = 0
	for i in range(n):
		if b[i] not in d:
			d[b[i]] = 1
		else:
			count += d[b[i]]
			d[b[i]] += 1
	print(count)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	book = {}
	for j in range(n):
		t = a[j] - j
		if t in book:
			book[t] += 1
		else:
			book[t] = 1
	ans = 0
	for j in book:
		if book[j] >= 2:
			ans += book[j] * (book[j] - 1) / 2
	print(int(ans))


import math

def sg(x):
	if x > 0:
		return True
	return False
T = int(input())
for _ in range(T):
	n = int(input())
	arr = input().split()
	arr = [int(x) for x in arr]
	tot = 0
	dk = {}
	for i in range(n):
		if arr[i] - i in dk:
			tot += dk[arr[i] - i]
			dk[arr[i] - i] += 1
		else:
			dk[arr[i] - i] = 1
	print(tot)


ll = lambda : map(int, input().split())
t = lambda : int(input())
ss = lambda : input()
lx = lambda x: map(int, input().split(x))
yy = lambda : print('YES')
nn = lambda : print('NO')
from math import log10, log2, ceil, factorial as fac, gcd, inf
for _ in range(t()):
	n = t()
	a = list(ll())
	for i in range(n):
		a[i] -= i + 1
	d = {}
	for i in a:
		if i not in d:
			d[i] = 0
		else:
			d[i] += 1
	c = 0
	for i in d.values():
		c += (i + 1) * i // 2
	print(c)


from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	d = defaultdict(int)
	for i in range(n):
		d[l[i] - i] += 1
	count = 0
	for i in d.keys():
		curr = d[i]
		if curr > 1:
			count += curr * (curr - 1) // 2
	print(count)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	c = 0
	hash_map = dict()
	for i in range(n):
		d = arr[i] - i
		if d in hash_map:
			c += hash_map[d]
			hash_map[d] += 1
		else:
			hash_map[d] = 1
	print(c)


from collections import defaultdict
from sys import stdin
from math import factorial
input = lambda : stdin.readline().strip()
for _ in range(int(input())):
	n = int(input())
	lst = [int(i) for i in input().split()]
	dict1 = defaultdict(int)
	for i in range(0, n):
		lst[i] = lst[i] - i
		dict1[lst[i] - 1] += 1
	nd = 0
	for i in dict1.keys():
		if dict1[i] >= 2:
			nd += dict1[i] * (dict1[i] - 1) // 2
	print(nd)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	x1 = dict()
	count = 0
	for i in range(n):
		z = arr[i] - i
		if z in x1:
			count += x1[z]
			x1[z] += 1
		else:
			x1[z] = 1
	print(count)


from collections import defaultdict, deque, Counter
import queue
from sys import stdin, stdout
from heapq import heappush, heappop
import math
import io
import os
import math
import bisect

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def digits(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def ceil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def mapin():
	return map(int, input().split())
t = int(input())
for _ in range(t):
	n = int(input())
	l = [int(x) for x in input().split()]
	for i in range(n):
		l[i] -= i
	d = defaultdict(lambda : 0)
	for i in range(n):
		d[l[i]] += 1
	ans = 0
	for i in d:
		temp = d[i]
		temp = temp * (temp - 1)
		temp //= 2
		ans += temp
	print(ans)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	ls = list(map(int, input().split()))
	ls2 = []
	for (i, v) in enumerate(ls):
		ls2.append(v - i)
	d = Counter(ls2)
	ans = 0
	for key in d:
		if d[key] > 1:
			ans += d[key] * (d[key] - 1) // 2
	print(ans)


t = int(input())
for _ in range(t):
	dictoflist = {}
	n = input()
	arr = list(map(int, input().split()))
	for i in range(len(arr)):
		dictoflist[arr[i] - i] = dictoflist.get(arr[i] - i, 0) + 1
	ans = 0
	for i in dictoflist:
		ans += dictoflist[i] * (dictoflist[i] - 1) // 2
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	for i in range(n):
		a[i] = a[i] - i - 1
	a.sort()
	ans = 0
	ca = 1
	for i in range(1, n):
		if a[i] == a[i - 1]:
			ca += 1
		else:
			ans += ca * (ca - 1) // 2
			ca = 1
	ans += ca * (ca - 1) // 2
	print(ans)


T = int(input())

def solve(arr):
	res = 0
	cts = {}
	for (i, x) in enumerate(arr):
		val = x - i
		if val not in cts:
			cts[val] = 1
		else:
			res += cts[val]
			cts[val] += 1
	return res
for _ in range(T):
	input()
	arr = list(map(int, input().split()))
	res = solve(arr)
	print(res)


cases = int(input())
for _ in range(cases):
	n = int(input())
	ints = [int(n) for n in input().split(' ')]
	counts = {}
	for i in range(n):
		if ints[i] - i not in counts.keys():
			counts[ints[i] - i] = 0
		counts[ints[i] - i] += 1
	count = 0
	for c in counts.values():
		count += c * (c - 1) // 2
	print(count)


results = []
for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	t = 0
	d = {}
	for (i, v) in enumerate(l):
		if v - i in d:
			t += d[v - i]
			d[v - i] += 1
		else:
			d[v - i] = 1
	results.append(t)
for i in results:
	print(i)


def solve(n, arr):
	d = {}
	for i in range(n):
		diff = arr[i] - i
		if diff not in d:
			d[diff] = 1
		else:
			d[diff] += 1
	ans = 0
	for c in d:
		if d[c] == 0 or d[c] == 1:
			pass
		else:
			ans += d[c] * (d[c] - 1) // 2
	return ans
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	print(solve(n, arr))


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	for i in range(n):
		a[i] -= i
	k = 0
	a.sort()
	cr = a[0]
	crk = 0
	for i in range(n):
		if a[i] == cr:
			k += crk
			crk += 1
		else:
			crk = 1
			cr = a[i]
	print(k)


from collections import defaultdict

def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		d = defaultdict(int)
		ans = 0
		for (i, x) in enumerate(a):
			ans += d[x - i]
			d[x - i] += 1
		print(ans)
main()


def fun(n, arr):
	d = {}
	ans = 0
	for (i, x) in enumerate(arr):
		if x - i in d:
			ans += d[x - i]
			d[x - i] += 1
		else:
			d[x - i] = 1
	return ans
for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = fun(n, arr)
	print(ans)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	dic = {}
	ans = 0
	for i in range(n):
		df = arr[i] - i
		if df in dic:
			ans += dic[df]
		if df not in dic:
			dic[df] = 1
		else:
			dic[df] += 1
	print(ans)


import collections
t = int(input())
for _ in range(t):
	n = int(input())
	array = list(map(int, input().split()))
	count = 0
	hm = collections.defaultdict()
	for (idx, num) in enumerate(array):
		current = num - idx
		if current in hm:
			count += hm[current]
			hm[current] += 1
		else:
			hm[current] = 1
	print(count)


from math import gcd
inp = int(input())
for _ in range(inp):
	n = int(input())
	p = list(map(int, input().split(' ')))
	d = {}
	res = 0
	for (i, v) in enumerate(p):
		s = v - i
		if s in d:
			res += d[s]
			d[s] = d[s] + 1
		else:
			d[s] = 1
	print(res)


from collections import defaultdict

def solution(n):
	ret = 0
	d_cnt = defaultdict(int)
	for (i, n) in enumerate(map(int, input().split()), 1):
		d_cnt[n - i] += 1
	for k in d_cnt:
		if d_cnt[k] > 1:
			ret += d_cnt[k] * (d_cnt[k] - 1) >> 1
	return ret
for _ in range(int(input())):
	print(solution(int(input())))


import sys
from math import *
input = sys.stdin.readline

def print(x, end='\n'):
	sys.stdout.write(str(x) + end)

def get_int():
	return int(input())

def get_list_ints():
	return list(map(int, input().split()))

def get_char_list():
	s = input()
	return list(s[:len(s) - 1])

def get_tuple_ints():
	return tuple(map(int, input().split()))

def print_iterable(p):
	print(' '.join(map(str, p)))

def main():
	a = get_int()
	for i in range(0, a):
		b = get_int()
		res = 0
		resarr = []
		arr = get_list_ints()
		for j in range(0, len(arr)):
			arr[j] = arr[j] - j
		arr.sort()
		for j in range(0, len(arr) - 1):
			if arr[j] == arr[j + 1]:
				res += 1
			else:
				resarr.append(res)
				res = 0
			if j == len(arr) - 2:
				resarr.append(res)
		sum = 0
		for k in resarr:
			sum += k * (k + 1) // 2
		print(sum)
	pass
main()


from collections import *

def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	count = 0
	offsets = Counter()
	for i in range(n):
		cur = arr[i] - i
		count += offsets[cur]
		offsets[cur] += 1
	return count
	pass

def main():
	cases = int(input())
	for t in range(cases):
		print(solve())
main()


for s in [*open(0)][2::2]:
	lst = [*map(int, s.split())]
	cnt = 0
	sz_lst = len(lst)
	st = {}
	cnt = 0
	for i in range(sz_lst):
		lol = lst[i] - i
		if lol in st:
			st[lol] += 1
		else:
			st[lol] = 1
	for (k, v) in st.items():
		cnt += v * (v - 1) // 2
	print(cnt)


size = len
tt = int(input())
for _ in range(tt):
	n = int(input())
	lst = list(map(int, input().split()))
	d = {}
	pos = []
	for i in range(size(lst)):
		pos.append(lst[i] - (i + 1))
	for j in pos:
		d[j] = d.get(j, 0) + 1
	count = 0
	for k in d.values():
		if k != 1:
			count += k * (k - 1) // 2
	print(count)


import collections
import itertools
import sys

def read_ints():
	return map(int, sys.stdin.readline().split())

def read_string():
	return sys.stdin.readline()[:-1]

def main():
	(t_n,) = read_ints()
	for i_t in range(t_n):
		(a_n,) = read_ints()
		a_seq = tuple(read_ints())
		assert len(a_seq) == a_n
		b_seq = tuple((a_seq[i] - i for i in range(a_n)))
		b_counter = collections.Counter(b_seq)
		result = sum((n * (n - 1) // 2 for n in b_counter.values()))
		print(result)
main()


from collections import Counter, deque, defaultdict, OrderedDict
import math
from bisect import bisect, bisect_left
import sys
import re
MOD = 10 ** 9 + 7
MAX = -sys.maxsize
MIN = sys.maxsize

class get:

	def int():
		return list(map(int, input().split()))

	def str():
		return input().split()

	def float():
		return list(map(float, input().split()))

	def map():
		return map(int, input().split())

def sqrt(x):
	return int(math.sqrt(x)) + 1

def gcd(*args):
	result = args[0]
	for item in args:
		result = math.gcd(result, item)
	return result

def LCM(a, b):
	return a * b // math.gcd(a, b)

def isPrime(n):
	if n == 1:
		return False
	for i in range(2, sqrt(n)):
		if n % i == 0:
			return False
	return True

def solve():
	n = int(input())
	a = get.int()
	for i in range(n):
		a[i] = a[i] - i
	d = Counter(a)
	res = 0
	for (a, b) in d.items():
		if b >= 2:
			res += b * (b - 1) // 2
	print(res)
t = int(input())
for tt in range(t):
	solve()


class Kickstart:

	def __init__(self):
		self.h = None

	def out_format(self, t, ans):
		return str(ans)

	def solve(self, k, arr):
		ans = 0
		cnt = {}
		for i in range(k - 1, -1, -1):
			d = arr[i] - i
			if d not in cnt:
				cnt[d] = 0
			ans += cnt[d]
			cnt[d] += 1
		return ans
t = int(input())
kick = Kickstart()
output = []
for i in range(t):
	k = int(input())
	arr = list(map(int, input().split()))
	output.append(kick.out_format(i + 1, kick.solve(k, arr)))
for ans in output:
	print(ans)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = dict()
	s = 0
	for i in range(0, len(l)):
		x = l[i] - i
		if x in d:
			d[x] = d[x] + 1
		else:
			d[x] = 1
	for (k, v) in d.items():
		s = s + v * (v - 1) // 2
	print(s)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import ceil

def prod(a, mod=10 ** 9 + 7):
	ans = 1
	for each in a:
		ans = ans * each % mod
	return ans

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
for _ in range(int(input()) if True else 1):
	n = int(input())
	a = list(map(int, input().split()))
	for i in range(n):
		a[i] -= i
	count = {}
	for i in a:
		count[i] = 1 if i not in count else count[i] + 1
	ans = 0
	for each in count:
		if count[each] < 2:
			continue
		ans += count[each] * (count[each] - 1) // 2
	print(ans)


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	count = 0
	cc = defaultdict(lambda : 0)
	for i in range(n):
		cc[a[i] - i] += 1
	for i in range(n):
		count += cc[a[i] - i] - 1
		cc[a[i] - i] -= 1
	print(count)


from collections import Counter

def getInvCount(arr, n):
	count = 0
	arr1 = list()
	for i in range(n):
		diff = int(arr[i]) - i
		arr1.append(diff)
	aa = Counter(arr1)
	for i in aa:
		m = aa[i]
		count += m * (m - 1) / 2
	return int(count)
m = int(input())
list1 = list()
while m > 0:
	n = int(input())
	arr = list()
	x = input().split()
	arr.append(x)
	arr = arr[0]
	ans = getInvCount(arr, n)
	list1.append(ans)
	m -= 1
for i in list1:
	print(i)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	k = {}
	ans = 0
	for i in range(n):
		diff = l[i] - i
		if diff in k:
			k[diff] += 1
		else:
			k[diff] = 1
	for i in k:
		ans += k[i] * (k[i] - 1) // 2
	print(ans)


for _ in range(int(input())):
	n = int(input())
	suma = 0
	zoz = [int(x) for x in input().split()]
	d = dict()
	for i in range(n):
		if zoz[i] - i in d:
			d[zoz[i] - i] += 1
		else:
			d[zoz[i] - i] = 1
	for i in d:
		suma += d[i] * (d[i] - 1) // 2
	print(suma)


from copy import deepcopy
import math
from collections import defaultdict as D
from itertools import permutations
from collections import deque
import random
import copy

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def frequency(l):
	d = {}
	for i in l:
		if i not in d:
			d[i] = 1
		else:
			d[i] += 1
	return d

def getSum(n):
	sum = 0
	for digit in str(n):
		sum += int(digit)
	return sum

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def listToString(s):
	str1 = ' '
	return str1.join(s)

def main():
	for yu in range(int(input())):
		n = int(input())
		a = list(map(int, input().strip().split()))
		mp = {}
		ans = 0
		for i in range(n):
			c = a[i] - i
			if c in mp:
				mp[c] += 1
				ans += mp[c]
			else:
				mp[c] = 0
		print(ans)
	return
main()


import sys, os.path
from collections import defaultdict
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = defaultdict(int)
	for i in range(n):
		a[i] -= i
	for i in range(n):
		d[a[i]] += 1
	ans = 0
	for i in d:
		ans += d[i] * (d[i] - 1) // 2
	print(ans)


import sys
import time
import os
from math import sqrt, log, log2, ceil, log10, gcd, floor, pow, sin, cos, tan, pi, inf, factorial
from copy import copy, deepcopy
from sys import exit, stdin, stdout
from collections import Counter, defaultdict, deque
from itertools import permutations
import heapq
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
mod = 1000000007
iinp = lambda : int(sys.stdin.readline())
inp = lambda : sys.stdin.readline().strip()
strl = lambda : list(inp().strip().split(' '))
intl = lambda : list(map(int, inp().split(' ')))
mint = lambda : map(int, inp().split())
flol = lambda : list(map(float, inp().split(' ')))
flush = lambda : stdout.flush()

def permute(nums):

	def fun(arr, nums, cur, v):
		if len(cur) == len(nums):
			arr.append(cur.copy())
		i = 0
		while i < len(nums):
			if v[i]:
				i += 1
				continue
			else:
				cur.append(nums[i])
				v[i] = 1
				fun(arr, nums, cur, v)
				cur.pop()
				v[i] = 0
				i += 1
		return arr
	res = []
	nums.sort()
	v = [0] * len(nums)
	return fun(res, nums, [], v)

def subsets(res, index, arr, cur):
	res.append(cur.copy())
	for i in range(index, len(arr)):
		cur.append(arr[i])
		subsets(res, i + 1, arr, cur)
		cur.pop()
	return res

def sieve(N):
	root = int(sqrt(N))
	primes = [1] * (N + 1)
	(primes[0], primes[1]) = (0, 0)
	for i in range(2, root + 1):
		if primes[i]:
			for j in range(i * i, N + 1, i):
				primes[j] = 0
	return primes

def bs(arr, l, r, x):
	if x < arr[0] or x > arr[len(arr) - 1]:
		return -1
	while l <= r:
		mid = l + (r - l) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	return -1

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	p = int(sqrt(n))
	for i in range(5, p + 1, 6):
		if n % i == 0 or n % (i + 2) == 0:
			return False
	return True

def solve():
	n = iinp()
	arr = intl()
	for i in range(n):
		arr[i] -= i
	c = Counter(arr)
	ans = 0
	for k in c.keys():
		ans += c[k] * (c[k] - 1) // 2
	print(ans)
start_time = time.time()
for _ in range(iinp()):
	solve()


t = int(input())
for e in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in range(n):
		l[i] -= i
		d[l[i]] = d.get(l[i], 0) + 1
	ans = 0
	for i in d.values():
		ans += i * (i - 1) // 2
	print(ans)


n = int(input())
for i in range(n):
	N = int(input())
	numbers = list(map(int, input().split()))
	dict = {}
	S = 0
	for i in range(len(numbers)):
		diff = numbers[i] - i
		if diff in dict:
			dict[diff] += 1
		else:
			dict[diff] = 1
	for x in dict:
		if dict[x] != 1:
			S += dict[x] * (dict[x] - 1) // 2
	print(S)


import math
from sys import stdin, stdout

def solve():
	t = int(input())
	while t:
		t -= 1
		n = int(input())
		a = list(map(int, input().strip().split()))
		p = {}
		for x in range(n):
			b = a[x] - x
			p[b] = p.get(b, 0) + 1
		ans = 0
		for x in p.values():
			ans += x * (x - 1)
		ans //= 2
		print(ans)
solve()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	h = {}
	ans = 0
	for i in range(n):
		x = a[i] - i
		if x in h:
			ans += h[x]
		else:
			h[x] = 0
		h[x] += 1
	print(ans)


import sys
input = sys.stdin.buffer.readline
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	d = {}
	for i in range(0, n):
		if arr[i] - (i + 1) not in d:
			d[arr[i] - (i + 1)] = 1
		else:
			d[arr[i] - (i + 1)] += 1
	ans = 0
	for key in d.keys():
		if d[key] > 1:
			k = d[key]
			ans += k * (k - 1) // 2
	print(ans)


import sys

def get_ints():
	return list(map(int, sys.stdin.readline().strip().split()))
testcases = int(input())
for testcase in range(testcases):
	n = int(input())
	arr = get_ints()
	dicts = {}
	for i in range(n):
		newelem = arr[i] - i
		if newelem not in dicts:
			dicts[newelem] = 0
		dicts[newelem] += 1
	ans = 0
	for (key, value) in dicts.items():
		maxsmin = max(0, value - 1)
		ans += value * maxsmin // 2
	print(ans)


from collections import Counter

def f(l):
	A = [l[i] - i for i in range(len(l))]
	x = Counter(A)
	tot = 0
	for i in x:
		tot += x[i] * (x[i] - 1) / 2
	return int(tot)

def foo(x):
	x = x.split()
	for (i, v) in enumerate(x):
		x[i] = int(v)
	return x
i1 = int(input())
ls = []
for a in range(i1):
	r1 = input()
	r2 = input()
	ans = f(foo(r2))
	ls.append(ans)
for j in ls:
	print(j)


def solve():
	n = int(input())
	arr = [int(x) for x in input().strip().split()]
	arr = [item - pos for (pos, item) in enumerate(arr, start=1)]
	arr.sort()
	arr.append(arr[0] - 1)
	(total_pairs, first_item, item_count) = (0, arr[0], 1)
	for item in arr[1:]:
		if item == first_item:
			item_count += 1
			continue
		total_pairs += (item_count - 1) * item_count // 2
		(first_item, item_count) = (item, 1)
	return total_pairs
for _ in range(int(input().strip())):
	print(solve())


answers = []

def solve(n, arr):
	count = 0
	store = {}
	for (i, ele) in enumerate(arr):
		diff = ele - i
		if diff not in store:
			store[diff] = 1
		else:
			store[diff] += 1
	for ele in store:
		l = store[ele]
		count += l * (l - 1) // 2
	answers.append(count)
T = int(input())
while T:
	n = int(input())
	arr = [int(x) for x in input().split()]
	solve(n, arr)
	T -= 1
for ans in answers:
	print(ans)


for g in [*open(0)][2::2]:
	a = list(map(int, g.split()))
	d = {}
	for i in range(len(a)):
		v = a[i] - i
		if v in d:
			d[v] += 1
		else:
			d[v] = 1
	t = 0
	for x in d:
		k = d[x]
		t += k * (k - 1) // 2
	print(t)


def solve(n, lst):
	dct = dict()
	ans = 0
	for i in range(n):
		s = lst[i] - i
		ans += dct.get(s, 0)
		dct[s] = dct.get(s, 0) + 1
	return ans
for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	print(solve(n, lst))


testCase = int(input())
while testCase > 0:
	testCase -= 1
	length = int(input())
	sum = 1
	array = sorted([int(x) - i for (i, x) in enumerate(input().split())])
	hash = {}
	for i in array:
		if i not in hash:
			hash[i] = 0
			sum = 1
		else:
			hash[i] += 1 * sum
			sum += 1
	sum = 0
	for i in hash.values():
		sum += i
	print(sum)


from collections import Counter, defaultdict, deque
import math
import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	arr = [int(_) for _ in input().split()]
	d = defaultdict(int)
	ans = 0
	for i in range(n):
		val = arr[i] - i
		ans += d[val]
		d[val] += 1
	print(ans)
tt = int(input())
for test in range(tt):
	solve()


for s in [*open(0)][2::2]:
	d = {}
	i = r = 0
	for x in s.split():
		v = d.get((k := (int(x) - i)), 0)
		r += v
		d[k] = v + 1
		i += 1
	print(r)


t = int(input())
for task in range(t):
	n = int(input())
	x = input().split()
	a = [int(x[i]) - i for i in range(n)]
	d = {}
	count = 0
	for i in a:
		if i in d:
			d[i] += 1
			count += d[i] - 1
		else:
			d[i] = 1
	print(count)


import sys
from collections import defaultdict
t = int(sys.stdin.readline())
MAX = 2 * int(100000.0)
for _ in range(t):
	n = int(sys.stdin.readline())
	S = list(map(int, sys.stdin.readline().split()))
	cnt = defaultdict(int)
	for i in range(n):
		num = S[i]
		cnt[num - i] += 1
	answer = 0
	for key in cnt.keys():
		x = cnt[key]
		if x < 2:
			continue
		answer += x * (x - 1) // 2
	print(answer)


for _ in range(int(input())):
	n = int(input())
	ls = list(map(int, input().split()))
	d = {}
	for (i, j) in enumerate(ls):
		d[j - i] = d.get(j - i, 0) + 1
	cnt = 0
	for (k, v) in d.items():
		if v > 1:
			cnt += v * (v - 1) / 2
	print(int(cnt))


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in range(n):
		d[l[i] - i] = d.get(l[i] - i, 0) + 1
	count = 0
	for x in d:
		c = d[x]
		count += c * (c - 1) // 2
	print(count)


t = int(input())
for test in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	need = {}
	count = 0
	for (i, x) in enumerate(arr):
		if x - i in need:
			count += need[x - i]
			need[x - i] += 1
		else:
			need[x - i] = 1
	print(count)


from sys import stdin, stdout
import math, bisect, heapq
from collections import Counter, deque, defaultdict
L = lambda : list(map(int, stdin.readline().strip().split()))
I = lambda : int(stdin.readline().strip())
S = lambda : stdin.readline().strip()
C = lambda : stdin.readline().strip().split()

def pr(a):
	print(' '.join(list(map(str, a))))

def solve():
	n = I()
	a = L()
	a = [a[i] - i for i in range(n)]
	d = Counter(a)
	ans = 0
	for i in d:
		ans += d[i] * (d[i] - 1) // 2
	print(ans)
for _ in range(I()):
	solve()


rn = lambda : int(input())
rl = lambda : [x for x in input().split()]
rln = lambda : [int(x) for x in input().split()]
rlfn = lambda : [float(x) for x in input().split()]

def solve():
	k = rn()
	l = rln()
	l2 = {}
	for (i, n) in enumerate(l):
		t = n - i
		l2[t] = l2.get(t, 0) + 1
	suma = 0
	for clave in l2:
		suma += l2[clave] * (l2[clave] - 1) // 2
	return [suma]
tests = rn()
for tc in range(1, tests + 1):
	rta = solve()
	print(' '.join(map(str, rta)))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	total = 0
	for i in range(n):
		x = a[i] - i
		if x in d:
			total += d[x]
			d[x] += 1
		else:
			d[x] = 1
	print(total)


import sys
from pprint import pprint

def do():

	def sigma1(n):
		return n * (n + 1) // 2
	n = int(input())
	dat = list(map(int, input().split()))
	dp = [0] * (n + 1 + n)
	offset = n
	for i in range(n):
		diff = dat[i] - (i + 1)
		dp[offset + diff] += 1
	res = 0
	for x in dp:
		if x == 0:
			continue
		if x == 1:
			continue
		res += sigma1(x - 1)
	print(res)
q = int(input())
for _ in range(q):
	do()


import os
import sys
from io import BytesIO, IOBase
from collections import Counter

def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		b = Counter()
		for i in range(n):
			b[a[i] - i] += 1
		ans = 0
		for i in b:
			z = b[i]
			ans += z * (z - 1) // 2
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import os
import sys
from io import BytesIO, IOBase
from collections import Counter
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def scanf(datatype=str):
	return datatype(sys.stdin.readline().rstrip())

def printf(answer=''):
	return sys.stdout.write(str(answer) + '\n')

def prints(answer):
	return sys.stdout.write(str(answer) + ' ')

def map_input(datatype=str):
	return map(datatype, sys.stdin.readline().split())

def list_input(datatype=str):
	return list(map(datatype, sys.stdin.readline().split()))

def testcase(number: int, solve_function):
	for i in range(number):
		printf(solve_function())

def solve():
	n = scanf(int)
	arr = list_input(int)
	ans = 0
	hashMap = Counter()
	for i in range(n):
		val = arr[i] - i
		ans += hashMap[val]
		hashMap[val] += 1
	return ans
t = scanf(int)
testcase(t, solve)


from collections import defaultdict
for _ in range(int(input())):
	d = defaultdict(int)
	n = int(input())
	ans = 0
	arr = list(map(int, input().split()))
	for x in range(n):
		diff = arr[x] - x
		d[diff] += 1
		ans = ans + (d[diff] - 1)
	print(ans)


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
inp = lambda : list(map(int, sys.stdin.readline().rstrip('\r\n').split()))
for _ in range(int(input())):
	n = int(input())
	a = inp()
	d = {}
	c = 0
	for (i, j) in enumerate(a):
		k = j - i
		if k in d:
			c += d[k]
			d[k] += 1
		else:
			d[k] = 1
	print(c)


def solve(n, lst):
	dct = dict()
	for i in range(n):
		s = lst[i] - i
		if s in dct:
			if len(dct[s]) != 0:
				dct[s].append(dct[s][-1] + 1)
			else:
				dct[s].append(1)
		else:
			dct[s] = []
	ans = 0
	for i in dct.values():
		ans += sum(i)
	return ans
for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	print(solve(n, lst))


import sys, collections
from math import comb
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	diff = list((a - b for (a, b) in zip(a, range(1, n + 1))))
	freq = collections.Counter(diff)
	total = 0
	for f in freq:
		if freq[f] >= 2:
			total += comb(freq[f], 2)
	print(total)


from io import BytesIO, IOBase
from math import sqrt
import sys, os
from os import path
inpl = lambda : list(map(int, input().split()))
inpm = lambda : map(int, input().split())
inpi = lambda : int(input())
inp = lambda : input()
(rev, ra, l) = (reversed, range, len)
P = print
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def B(n):
	return bin(n).replace('0b', '')

def factors(n):
	arr = []
	for i in ra(2, int(sqrt(n)) + 1):
		if n % i == 0:
			arr.append(i)
			if i * i != n:
				arr.append(int(n / i))
	return arr

def dfs(arr, n):
	pairs = [[i + 1] for i in ra(n)]
	vis = [0] * (n + 1)
	for i in ra(l(arr)):
		pairs[arr[i][0] - 1].append(arr[i][1])
	pairs[arr[i][1] - 1].append(arr[i][0])
	comp = []
	for i in ra(n):
		stack = [pairs[i]]
		temp = []
		if vis[stack[-1][0]] == 0:
			while len(stack) > 0:
				if vis[stack[-1][0]] == 0:
					temp.append(stack[-1][0])
					vis[stack[-1][0]] = 1
					s = stack.pop()
					for j in s[1:]:
						if vis[j] == 0:
							stack.append(pairs[j - 1])
				else:
					stack.pop()
			comp.append(temp)
	return comp
from bisect import bisect_left as bl
from bisect import bisect_right as br
import sys, operator, math, operator
from collections import Counter
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
import random
tc = inpi()
while tc:
	tc -= 1
	n = inpi()
	li = inpl()
	omap = {}
	for i in ra(n):
		if li[i] - i in omap:
			omap[li[i] - i] += 1
		else:
			omap[li[i] - i] = 1
	ans = 0
	for (k, v) in omap.items():
		ans += v * (v - 1) / 2
	P(int(ans))


import sys
input = sys.stdin.readline
(inp, ip) = (lambda : int(input()), lambda : [int(w) for w in input().split()])
for _ in range(1, inp() + 1):
	n = inp()
	x = ip()
	y = [x[i] - i for i in range(n)]
	dt = {}
	for i in y:
		dt[i] = dt.get(i, 0) + 1
	ans = 0
	for i in dt:
		ans += dt[i] * (dt[i] - 1) // 2
	print(ans)


import sys
from collections import defaultdict

def solve(n, li):
	temp = defaultdict(int)
	ans = 0
	for (i, j) in enumerate(li):
		ans += temp[j - i]
		temp[j - i] += 1
	return ans
for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	print(solve(n, li))


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	count = 0
	dic = dict()
	for i in range(n):
		res = arr[i] - i
		try:
			dic[res] += 1
		except KeyError:
			dic[res] = 1
	for x in dic.values():
		count += x * (x - 1) // 2
	print(count)


t = int(input())
list_ans = []
for _ in range(t):
	dict1 = {}
	ans = 0
	n = int(input())
	list1 = list(map(int, input().split()))
	for i in range(n):
		list1[i] -= i
	for x in list1:
		if x in dict1:
			dict1[x] += 1
		else:
			dict1[x] = 1
	for x in dict1.values():
		if x >= 2:
			ans += x * (x - 1) // 2
	list_ans.append(ans)
for item in list_ans:
	print(item)


import sys
N = int(200000.0 + 5)
sys.setrecursionlimit(N)

def charming():
	n = int(input())
	a = [0] + list(map(int, input().split()))
	d = dict()
	res = 0
	for i in range(1, n + 1):
		a[i] = a[i] - i
		if a[i] in d:
			d[a[i]] += 1
		else:
			d[a[i]] = 1
	for i in range(1, n + 1):
		d[a[i]] -= 1
		res += d[a[i]]
	print(res)
for t in range(int(input())):
	charming()


t = int(input())
for j in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	ans = 0
	for i in range(0, n):
		div = a[i] - i
		b.append(div)
	b.sort()
	prev = b[0]
	same = 0
	for i in range(0, n):
		if b[i] == prev:
			ans += same
			same += 1
		else:
			same = 1
			prev = b[i]
	print(ans)


import math
import sys
import random
t = int(input())
for _ in range(t):
	n = int(input())
	l = [0] * (2 * n + 1)
	arr = list(map(int, input().split()))
	for i in range(n):
		arr[i] = arr[i] - (i + 1)
		l[arr[i] + n] += 1
	c = 0
	for i in range(2 * n + 1):
		if l[i] < 2:
			continue
		c += l[i] * (l[i] - 1) // 2
	print(c)


def solve(l, n):
	d = {}
	for i in range(n):
		if l[i] - i in d:
			d[l[i] - i] += 1
		else:
			d[l[i] - i] = 1
	res = 0
	for i in d.values():
		res = res + i * (i - 1) // 2
	return res
for _ in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	print(solve(l, n))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	q = {}
	for i in range(n):
		if a[i] - i in q.keys():
			q[a[i] - i] += 1
		else:
			q[a[i] - i] = 1
	ans = 0
	for el in q.values():
		ans += el * (el - 1) // 2
	print(ans)


t = int(input())
for i in range(t):
	n = input()
	nums = list(map(int, input().split(' ')))
	d = {}
	count = 0
	for i in range(len(nums)):
		if nums[i] - i in d:
			count += d[nums[i] - i]
			d[nums[i] - i] += 1
		else:
			d[nums[i] - i] = 1
	print(count)


from collections import Counter

def same(l):
	dl = [int(l[i]) - i for i in range(len(l))]
	dicto = Counter(dl)
	s = 0
	for j in dicto:
		s += dicto[j] * (dicto[j] - 1) // 2
	return str(s)
t = input()
no = int(t)
s = ''
for i in range(no):
	r1 = input()
	r2 = input().split(' ')
	s += same(r2) + '\n'
print(s)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, values, counts, ans) = (int(input()), [int(i) for i in input().split()], {}, 0)
	for i in range(n):
		check = values[i] - i
		counts[check] = counts.get(check, 0) + 1
	for same in counts:
		ans += counts[same] * (counts[same] - 1) // 2
	print(ans)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	t = []
	for i in range(n):
		t.append(arr[i] - i)
	map_val = {}
	for i in range(n):
		if t[i] not in map_val:
			map_val[t[i]] = 1
		else:
			map_val[t[i]] += 1
	res = 0
	for i in map_val:
		if map_val[i] > 1:
			res += abs(map_val[i]) * abs(map_val[i] - 1) // (1 + 1)
	print(res)


import sys
from collections import defaultdict
input = sys.stdin.readline
t = int(input())
results = []
while t > 0:
	t -= 1
	n = int(input())
	arr = list(map(int, input().rstrip().split()))
	dif = defaultdict(int)
	for i in range(n):
		dif[i + 1 - arr[i]] += 1
	num = 0
	for (key, value) in dif.items():
		if value >= 2:
			num += value * (value - 1) // 2
	results.append(num)
for i in results:
	print(i)


import sys

def input():
	return sys.stdin.readline().rstrip()
from collections import defaultdict

def slv():
	n = int(input())
	a = list(map(int, input().split()))
	d = defaultdict(int)
	for (i, v) in enumerate(a):
		d[v - i] += 1
	ans = sum((value * (value - 1) // 2 for value in d.values()))
	print(ans)
	return

def main():
	t = int(input())
	for i in range(t):
		slv()
	return
main()


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in range(n):
		if not l[i] - i in d:
			d[l[i] - i] = 1
		else:
			d[l[i] - i] += 1
	ans = 0
	for i in d.values():
		ans += i * (i - 1) // 2
	print(ans)


import sys
input = sys.stdin.buffer.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	diff = [0] * (2 * n - 1)
	for i in range(n):
		diff[a[i] - 1 - i] += 1
	tot = 0
	for i in diff:
		tot += i * (i - 1) // 2
	print(tot)


import sys
from collections import *
input = lambda : sys.stdin.readline()
int_arr = lambda : list(map(int, input().split()))
str_arr = lambda : list(map(str, input().split()))
get_str = lambda : map(str, input().split())
get_int = lambda : map(int, input().split())
get_flo = lambda : map(float, input().split())

def solve(n, arr):
	count = 0
	c = 1
	a = []
	for i in range(n):
		a.append(arr[i] - i)
	for (key, freq) in Counter(a).items():
		if freq > 1:
			count += freq * (freq - 1) / 2
	print(int(count))
for _ in range(int(input())):
	n = int(input())
	arr = int_arr()
	solve(n, arr)


def findPairs(arr, n):
	diffMap = {}
	pairs = 0
	for i in range(n):
		arr[i] = arr[i] - i
		if arr[i] not in diffMap.keys():
			diffMap[arr[i]] = 1
		else:
			diffMap[arr[i]] += 1
	for (key, val) in diffMap.items():
		if val > 1:
			pairs += val * (val - 1) // 2
	return pairs
t = int(input())
for case in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	print(findPairs(lst, n))


def same():
	n = int(input())
	arr = list(map(int, input().split()))
	d = dict()
	res = 0
	for i in range(n):
		t = arr[i] - i
		if d.get(t, 0) == 0:
			d[t] = 0
		res += d[t]
		d[t] += 1
	return res
for i in range(int(input())):
	print(same())


import collections
for _ in range(int(input())):
	n = int(input())
	v = list(map(int, input().split()))
	v = [v[i] - i for i in range(len(v))]
	d = collections.Counter(v)
	ans = 0
	for i in d.values():
		ans += i * (i - 1) // 2
	print(ans)


def count(a):
	d = dict()
	for i in range(len(a)):
		d[a[i] - i] = d.get(a[i] - i, 0) + 1
	res = 0
	for x in d:
		ctr = d[x]
		res = res + ctr * (ctr - 1) // 2
	return res
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	print(count(a))


import math

def main():
	for _ in range(int(input())):
		n = input()
		s = list(map(int, input().split()))
		print(get(s))

def get(s):
	p = []
	step = 0
	for (i, v) in enumerate(s):
		p.append(v - i)
	dict = {}
	for n in p:
		if not n in dict.keys():
			dict[n] = 1
		else:
			dict[n] += 1
	for i in dict.values():
		if i != 1:
			i -= 1
			step += i * (i + 1) / 2
	return int(step)
main()


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	(count, res) = ({}, 0)
	for i in range(n):
		num = arr[i] - i
		if num in count:
			res += count[num]
			count[num] += 1
		else:
			count[num] = 1
	print(res)


def solve():
	t = int(input())
	while t > 0:
		t -= 1
		n = int(input())
		diff = {}
		ans = 0
		for (num, i) in zip(input().split(), range(n)):
			key = int(num) - i
			if key not in diff:
				diff[key] = 1
			else:
				ans += diff[key]
				diff[key] += 1
		print(int(ans))
solve()


import math

def sol(A):
	dic = {}
	ans = 0
	for i in range(len(A)):
		key = A[i] - i
		if key in dic:
			dic[key] += 1
		else:
			dic[key] = 1
	for key in dic:
		ans += math.comb(dic[key], 2)
	return ans
x = int(input())
for _ in range(x):
	y = int(input())
	A = list(map(int, input().split()))
	print(sol(A))


import collections as coll
import sys
import math as mt
import time
sys.setrecursionlimit(1000000)

def uno():
	return int(sys.stdin.readline().strip())

def dos():
	return sys.stdin.readline().strip()

def tres():
	return map(int, sys.stdin.readline().strip().split())

def cuatro():
	return sys.stdin.readline().strip().split()
time1 = time.time()
for _ in range(uno()):
	n = uno()
	a = list(tres())
	(ans, d) = (0, coll.defaultdict(lambda : 0))
	for i in range(n):
		d[a[i] - i] += 1
	for i in d:
		ans += d[i] * (d[i] - 1) // 2
	print(ans)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	d = {}
	for i in range(n):
		d[arr[i] - i] = d.get(arr[i] - i, 0) + 1
	ans = 0
	for i in d:
		n_ = d[i]
		ans += n_ * (n_ - 1) // 2
	print(ans)


for _ in range(int(input())):
	n = int(input())
	d = {}
	cnt = 0
	value = i = 0
	for k in map(int, input().split()):
		value = d.get(k - i, 0)
		cnt += value
		d[k - i] = value + 1
		i += 1
	print(cnt)


from sys import *
from collections import defaultdict
input = stdin.readline
I = int
R = range
listInput = lambda : list(map(int, input().strip().split()))
lineInput = lambda : map(int, input().strip().split())

def main():
	for _ in R(I(input())):
		(n,) = lineInput()
		arr = listInput()
		d = defaultdict(int)
		ans = 0
		for i in range(n):
			dif = arr[i] - (i + 1)
			d[dif] += 1
		for v in d.values():
			temp = v - 1
			ans += temp * (temp + 1) // 2
		else:
			print(ans)
main()


def solve():
	cases = int(input())
	for t in range(cases):
		input()
		nums = list(map(int, input().rstrip().split()))
		search = dict()
		count = 0
		for i in range(len(nums)):
			diff = nums[i] - i
			if diff in search:
				count += search[diff]
				search[diff] += 1
			else:
				search[diff] = 1
		print(count)
solve()


t = int(input())
testcases = [(int(input()), list(map(int, input().split()))) for _ in range(t)]
for testcase in testcases:
	counts = {}
	for (i, element) in enumerate(testcase[1]):
		new_element = element - i
		if new_element in counts:
			counts[new_element] += 1
		else:
			counts[new_element] = 1
	count = 0
	for count_ in counts.values():
		count += count_ * (count_ - 1) // 2
	print(count)


def solve():
	n = int(input())
	l = list(map(int, input().split()))
	d = dict()
	ans = 0
	for i in range(n):
		temp = l[i] - i
		if d.get(temp, 0) == 0:
			d[temp] = 0
		ans += d[temp]
		d[temp] += 1
	return ans
for _ in range(int(input())):
	print(solve())


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s = 0
	k = {}
	for i in range(n):
		k[a[i] - i] = k.get(a[i] - i, 0) + 1
	for u in k.keys():
		s += k[u] * (k[u] - 1) // 2
	print(s)
	print()


import sys, os, io
from sys import stdin, stdout
from math import log, gcd, ceil
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import math
alphabets = list('abcdefghijklmnopqrstuvwxyz')

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def si():
	return input()

def prefix_sum(arr):
	r = [0] * (len(arr) + 1)
	for (i, el) in enumerate(arr):
		r[i + 1] = r[i] + el
	return r

def divideCeil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')

def power_set(L):
	cardinality = len(L)
	n = 2 ** cardinality
	powerset = []
	for i in range(n):
		a = bin(i)[2:]
		subset = []
		for j in range(len(a)):
			if a[-j - 1] == '1':
				subset.append(L[j])
		powerset.append(subset)
	powerset_orderred = []
	for k in range(cardinality + 1):
		for w in powerset:
			if len(w) == k:
				powerset_orderred.append(w)
	return powerset_orderred

def fastPlrintNextLines(a):
	print('\n'.join(map(str, a)))

def sortByFirstAndSecond(A):
	A = sorted(A, key=lambda x: x[0])
	A = sorted(A, key=lambda x: x[1])
	return list(A)
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	count = 0
	dic = {}
	for i in range(0, n):
		if li[i] - i - 1 not in dic:
			dic[li[i] - i - 1] = 1
		else:
			dic[li[i] - i - 1] += 1
	ans = 0
	for key in dic:
		val = dic[key]
		ans += val * (val - 1) // 2
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	s = 0
	m = 0
	mn = 100000000
	arr = list(map(int, input().split()))
	for j in range(n):
		arr[j] = arr[j] - j
		m = max(m, arr[j])
		mn = min(mn, arr[j])
	kol = [0] * (m + 1 + abs(mn))
	for j in range(n):
		kol[arr[j] + abs(mn)] += 1
	for j in range(m + 1 + abs(mn)):
		s += kol[j] * (kol[j] - 1) / 2
	print(int(s))


from collections import defaultdict
test_cases = int(input())

def handle():
	offset_groups = defaultdict(int)
	input()
	for (index, value) in enumerate([int(s) for s in input().split(' ')]):
		offset_groups[value - index] += 1
	total = 0
	for (key, value) in offset_groups.items():
		if value >= 2:
			total += value * (value - 1) // 2
	return total
for _ in range(test_cases):
	print(handle())


from collections import Counter

def run(n, arr):
	arr = [num - ind for (ind, num) in enumerate(arr)]
	counter = Counter(arr)
	ans = 0
	for c in counter.values():
		ans += c * (c - 1) // 2
	return ans
testcase = int(input())
for _ in range(testcase):
	n = int(input())
	arr = [int(num) for num in input().split()]
	ans = run(n, arr)
	print(ans)


from sys import stdin

def get_ints():
	return list(map(int, stdin.readline().strip().split()))
for _ in range(int(input())):
	ans = 0
	n = int(input())
	ar = get_ints()
	freq = [0] * (n + 1) * 2
	ans = 0
	for i in range(n):
		ar[i] -= i
		ans += freq[ar[i] + n + 1]
		freq[ar[i] + n + 1] += 1
	print(ans)


n = int(input())
for i in range(n):
	j = int(input())
	l = list(map(int, input().split()))
	dic = {}
	for i in range(len(l)):
		s = l[i] - i
		if s in dic:
			dic[s] += 1
		else:
			dic[s] = 1
	d = 0
	for i in list(dic.values()):
		if i > 1:
			d += i * (i - 1) // 2
	print(d)


from math import ceil
t = int(input())
while t > 0:
	d = dict()
	n = int(input())
	l = list(map(int, input().split()))
	for i in range(n):
		k = l[i] - i
		d[k] = d.get(k, 0) + 1
	c = 0
	for i in d.values():
		c += i * (i - 1) // 2
	print(c)
	t -= 1


def main():
	n = int(input())
	a = list(map(int, input().split()))
	dictt = {}
	for i in range(n):
		a[i] -= i
	for x in a:
		if x in dictt:
			dictt[x] = dictt[x] + 1
		else:
			dictt[x] = 1
	ans = 0
	for x in dictt:
		cnt = dictt[x]
		ans += cnt * (cnt - 1) / 2
	print(int(ans))
t = int(input())
while t > 0:
	main()
	t -= 1


def cpr(arr):
	count = 0
	diff_dict = {}
	for (i, num) in enumerate(arr):
		diff = num - i
		if diff in diff_dict:
			count += diff_dict[diff]
			diff_dict[diff] += 1
		else:
			diff_dict[diff] = 1
	return count
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	print(cpr(a))


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		res = 0
		a_map = {}
		for i in range(n):
			a[i] -= i
			if a[i] not in a_map:
				a_map[a[i]] = 0
			res += a_map[a[i]]
			a_map[a[i]] += 1
		print(res)
main()


def sol(arr):
	arr = [int(i) for i in arr]
	counter = 0
	delt = {}
	for i in range(len(arr)):
		if arr[i] - i not in delt.keys():
			delt[arr[i] - i] = 1
		else:
			delt[arr[i] - i] += 1
			counter += delt[arr[i] - i] - 1
	print(counter)

def main():
	for i in range(int(input())):
		n = int(input())
		arr = input().split()
		sol(arr)
main()


from collections import defaultdict
import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	v = list(map(int, input().split()))
	d = defaultdict(int)
	for i in range(len(v)):
		d[v[i] - i] += 1
	ans = 0
	for i in d:
		if d[i] > 1:
			ans += d[i] * (d[i] - 1) // 2
	print(ans)


import sys
input = sys.stdin.readline
from itertools import accumulate, groupby
from math import sqrt
from collections import Counter
import bisect
from heapq import heappop, heappush
for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	cnt = Counter()
	ans = 0
	for (i, a) in enumerate(A):
		ans += cnt[a - i]
		cnt[a - i] += 1
	print(ans)


from collections import Counter

def fun(ls, n):
	ans = []
	count = 0
	for (i, val) in enumerate(ls):
		ans.append(val - i)
	ctr = Counter(ans)
	for (key, val) in ctr.items():
		if val >= 2:
			count += val * (val - 1) // 2
	print(count)
T = int(input())
for _ in range(T):
	n = int(input())
	ls = list(map(int, input().split()))
	fun(ls, n)


tc = int(input())
while tc:
	tc -= 1
	size = int(input())
	li = [int(i) for i in input().split()]
	d = {}
	count = 0
	for i in range(size):
		var = li[i] - i
		if d.get(var, 0) == 0:
			d[var] = 0
		count += d[var]
		d[var] += 1
	print(count)


def solve(x, n):
	y = []
	total = 0
	for i in range(n):
		y.append(int(x[i]) - i)
	count = {}
	for i in range(n):
		temp = y[i]
		if temp in count:
			count[temp] += 1
		else:
			count[temp] = 1
	for value in count.values():
		if value >= 2:
			total += value * (value - 1) // 2
	return total
for q in range(int(input())):
	n = int(input())
	x = input().split()
	print(solve(x, n))


def arrIn():
	return list(map(int, input().split()))

def mapIn():
	return map(int, input().split())
for ii in range(int(input())):
	n = int(input())
	a = arrIn()
	arr = [0] * n
	for i in range(n):
		arr[i] = a[i] - i
	d = {}
	for i in range(n):
		d[arr[i]] = 0
	for i in range(n):
		d[arr[i]] += 1
	ans = 0
	for y in d:
		x = d[y]
		ans += x * (x - 1) // 2
	print(ans)


from collections import Counter
from sys import stdin

def read_int():
	return int(stdin.readline())

def read_ints():
	return map(int, stdin.readline().split())
t = read_int()
for case_num in range(t):
	n = read_int()
	a = list(read_ints())
	cnt = Counter()
	ans = 0
	for (i, num) in enumerate(a):
		ans += cnt[num - i]
		cnt[num - i] += 1
	print(ans)


test = int(input())
for t in range(test):
	n = int(input())
	a = [int(i) for i in input().split(' ')]
	b = []
	for i in range(n):
		b.append(a[i] - i)
	b.sort()
	s = [0 for i in range(0, 2 * n + 2)]
	for e in b:
		s[n + e] += 1
	ans = 0
	for e in s:
		ans += e * (e - 1) / 2
	print(int(ans))


test_num = int(input())
for test in range(test_num):
	nums = dict()
	n = int(input())
	num_list = input().split()
	for i in range(len(num_list)):
		num = int(num_list[i])
		added_num = num - i
		nums[added_num] = nums.get(added_num, 0) + 1
	total = 0
	for (k, v) in nums.items():
		if v:
			total += v * (v - 1) // 2
	nums.clear()
	print(total)


import math
import sys

def scan():
	return list(map(int, sys.stdin.readline().strip().split()))

def solution():
	for _ in range(int(input())):
		n = int(input())
		a = scan()
		b = {}
		for i in range(n):
			d = a[i] - i
			if d in b:
				b[d] += 1
			else:
				b[d] = 1
		c = 0
		for i in b:
			if b[i] > 1:
				c += b[i] * (b[i] - 1) // 2
		print(c)
solution()


def solve(l, n):
	t = {}
	for i in range(n):
		if l[i] - i in t:
			t[l[i] - i] += 1
		else:
			t[l[i] - i] = 1
	ans = 0
	for i in t.values():
		ans = ans + i * (i - 1) // 2
	return ans
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	print(solve(l, n), end=' ')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in range(n):
		if l[i] - i in d:
			d[l[i] - i] += 1
		else:
			d[l[i] - i] = 1
	out = 0
	for i in d:
		out += d[i] * (d[i] - 1) // 2
	print(out)


import sys
import math
from math import factorial, inf, gcd, sqrt
from heapq import *
from functools import *
from itertools import *
from collections import *
from typing import *
from bisect import *
import random
sys.setrecursionlimit(10 ** 5)

def rarray():
	return [int(i) for i in input().split()]
t = 1
t = int(input())
for ii in range(t):
	n = int(input())
	a = rarray()
	m = Counter()
	ans = 0
	for (i, j) in enumerate(a):
		a[i] -= i
		ans += m.get(a[i], 0)
		m[a[i]] += 1
	print(ans)


import sys
import os.path
from collections import *
import math
import bisect
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
t = int(input())
while t:
	t -= 1
	n = int(input())
	arr = [int(x) for x in input().split()]
	x = arr[0]
	if n == 1:
		print(0)
	else:
		h = Counter()
		for i in range(n):
			h[arr[i] - i] += 1
		cnt = 0
		for i in h:
			x = h[i]
			cnt += x * (x - 1) // 2
		print(cnt)


from collections import Counter

def getCount(n, arr):
	res = [arr[i] - i - 1 for i in range(n)]
	resss = [int(v * (v - 1) / 2) for (k, v) in Counter(res).items() if v > 1]
	return sum(resss)
taskNum = int(input())
for i in range(taskNum):
	n = int(input())
	arr = list(map(int, input().split()))
	print(getCount(n, arr))


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = defaultdict(int)
	for i in range(len(a)):
		a[i] -= i
		d[a[i]] += 1
	count = 0
	for i in d:
		if d[i] != 1:
			count += (d[i] - 1) * d[i] // 2
	print(count)


import sys

def rl():
	return sys.stdin.readline().strip()

def rl_types(types):
	str_list = [x for x in sys.stdin.readline().strip().split(' ')]
	return [types[i](str_list[i]) for i in range(len(str_list))]

def pr(something):
	sys.stdout.write(str(something) + '\n')

def pra(array):
	sys.stdout.write(' '.join([str(x) for x in array]) + '\n')

def solve(array):
	w_offset = [x - i for (i, x) in enumerate(array)]
	seen_counts = {}
	tot = 0
	for e in w_offset:
		if not e in seen_counts:
			seen_counts[e] = 1
		else:
			tot += seen_counts[e]
			seen_counts[e] += 1
	return tot
NT = int(rl())
for ti in range(NT):
	_ = rl()
	array = [int(x) for x in rl().split(' ')]
	cnt = solve(array)
	pr(cnt)


import sys, math
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	d = {}
	for i in range(n):
		if a[i] - i in d:
			d[a[i] - i] += 1
		else:
			d[a[i] - i] = 1
	ans = 0
	for i in d:
		if d[i] > 1:
			ans += math.comb(d[i], 2)
	print(ans)


def fun(n):
	return n * (n - 1) // 2
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	ll = [l[i] - i for i in range(n)]
	mp = {}
	for i in ll:
		try:
			mp[i] += 1
		except:
			mp[i] = 1
	res = 0
	for i in list(mp.keys()):
		if mp[i] > 1:
			res += fun(mp[i])
	print(res)


import math

def getint():
	return [int(i) for i in input().split()]

def getstr():
	return [str(i) for i in input().split()]

def solve():
	dic = {}
	ans = 0
	n = int(input())
	a = getint()
	for i in range(n):
		if a[i] - i in dic:
			dic[a[i] - i] += 1
		else:
			dic[a[i] - i] = 1
	for i in dic.values():
		ans += i * (i - 1) // 2
	print(ans)
for _ in range(int(input())):
	solve()


def sd_count(ls, n):
	dic = dict()
	for i in range(n):
		dic[ls[i] - i] = dic.get(ls[i] - i, 0) + 1
	ret = 0
	for x in dic:
		ret += dic[x] * (dic[x] - 1) // 2
	return ret
import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	print(sd_count(a, n))


def ans(a, n):
	d = {}
	for i in range(n):
		d[a[i] - i] = d.get(a[i] - i, 0) + 1
	k = 0
	for x in d:
		temp = d[x]
		k += temp * (temp - 1) // 2
	return k
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().strip().split()]
	print(ans(a, n))


import sys
input = sys.stdin.readline
for _ in [0] * int(input()):
	n = int(input())
	a = list(input().split())
	d = {}
	x = s = 0
	for i in a:
		req = int(i) - x
		if req not in d:
			d[req] = 0
		else:
			d[req] = d[req] + 1
			s = s + d[req]
		x = x + 1
	print(s)


t = int(input())

def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	d = dict()
	for i in range(len(arr)):
		hash = i - arr[i]
		if not hash in d.keys():
			d[hash] = 1
		else:
			d[hash] += 1
	ans = 0
	for i in d.keys():
		temp = d[i]
		ans += temp * (temp - 1) // 2
	print(ans)
for i in range(t):
	solve()


def count_pairs(arr):
	count = 0
	diff_dict = {}
	for i in range(len(arr)):
		diff = arr[i] - i
		if diff in diff_dict:
			count += diff_dict[diff]
		if diff in diff_dict:
			diff_dict[diff] += 1
		else:
			diff_dict[diff] = 1
	return count
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print(count_pairs(a))


from collections import defaultdict
t = int(input())
for i in range(t):
	n = int(input())
	ar = list(map(int, input().split()))
	d = defaultdict(int)
	ans = 0
	for i in range(n):
		ans += d[ar[i] - i]
		d[ar[i] - i] += 1
	print(ans)


for s in [*open(0)][2::2]:
	d = {}
	i = a = 0
	for n in map(int, s.split()):
		g = d.get(n - i, 0)
		a += g
		d[n - i] = g + 1
		i += 1
	print(a)


import sys, heapq
from collections import defaultdict, deque
import math
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def main():
	test = inp()
	for _ in range(test):
		n = inp()
		nums = inlt()
		difference = defaultdict(int)
		result = 0
		for i in range(n):
			if difference[nums[i] - i]:
				result += difference[nums[i] - i]
			difference[nums[i] - i] += 1
		print(result)
main()


from collections import defaultdict, deque, Counter
from heapq import heapify, heappop, heappush
import math
from copy import deepcopy
from itertools import combinations, permutations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
import sys

def input():
	return sys.stdin.readline().rstrip()

def getN():
	return int(input())

def getNM():
	return map(int, input().split())

def getList():
	return list(map(int, input().split()))

def getArray(intn):
	return [int(input()) for i in range(intn)]
mod = 10 ** 9 + 7
MOD = 998244353
INF = float('inf')
eps = 10 ** (-10)
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
T = getN()
for _ in range(T):
	N = getN()
	A = getList()
	A = [A[i] - i for i in range(N)]
	d = defaultdict(int)
	for a in A:
		d[a] += 1
	ans = 0
	for (k, v) in d.items():
		ans += v * (v - 1) // 2
	print(ans)


import sys
input = sys.stdin.readline

def mp():
	return map(int, input().split())

def lmp():
	return list(map(int, input().split()))

def mps(A):
	return [tuple(map(int, input().split())) for _ in range(A)]
import math
import bisect
from copy import deepcopy as dc
from itertools import accumulate
from collections import Counter, defaultdict, deque

def ceil(U, V):
	return (U + V - 1) // V

def modf1(N, MOD):
	return (N - 1) % MOD + 1
inf = int(1e+20)
mod = int(1000000000.0 + 7)
t = int(input())
for _ in range(t):
	n = int(input())
	a = lmp()
	for i in range(1, n + 1):
		a[i - 1] -= i
	c = list(Counter(a).values())
	ans = 0
	for i in c:
		ans += i * (i - 1) // 2
	print(ans)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().strip().split()))
	d = {}
	for i in range(n):
		l[i] = l[i] - i
		d[l[i]] = d.get(l[i], 0) + 1
	c = 0
	for i in d:
		if d[i] >= 2:
			c = c + (d[i] - 1) * d[i] // 2
	print(c)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	for j in range(n):
		b.append(a[j] - (j + 1))
	ans = 0
	dic = {}
	for j in b:
		if j in dic:
			dic[j] += 1
		else:
			dic[j] = 1
	for j in dic:
		ans += dic[j] * (dic[j] - 1) // 2
	print(ans)


for tc in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	aa = [a[i] - i for i in range(len(a))]
	c = {}
	for i in aa:
		if i in c:
			c[i] += 1
		else:
			c[i] = 1
	ans = 0
	for i in c:
		ans += c[i] * (c[i] - 1) // 2
	print(ans)