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$$$.

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$$$.

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

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type key struct {
	n, r int
}

var nCrMemoi map[key]uint64 = map[key]uint64{}

func nCr(n, r int) uint64 {
	if r == 0 {
		return 1
	}

	if n == r {
		return 1
	}

	var answer uint64
	k := key{n, r}

	if val, ok := nCrMemoi[k]; ok {
		answer = val
	} else {
		answer = nCr(n-1, r-1) + nCr(n-1, r)
		nCrMemoi[k] = answer
	}

	return answer
}

func logic(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n int
	fmt.Fscan(in, &n)

	for i := 0; i < n; i++ {
		hashmap := map[int]int{}
		var size int
		fmt.Fscan(in, &size)

		for j := 0; j < size; j++ {
			var val int
			fmt.Fscan(in, &val)

			subtraction := val - j
			hashmap[subtraction]++
		}

		var result uint64
		for _, val := range hashmap {
			if val > 1 {
				result += nCr(val, 2)
			}
		}

		fmt.Fprintln(out, result)
	}
}

func main() {
	logic(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

// func factorial(n int) int {
// 	result := 1

// 	for i := 1; i <= n; i++ {
// 		result *= i
// 	}

// 	return result
// }

func logic(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n int
	fmt.Fscan(in, &n)

	for i := 0; i < n; i++ {
		hashmap := map[int]int{}
		var size int
		fmt.Fscan(in, &size)

		var result int64
		for j := 0; j < size; j++ {
			var val int
			fmt.Fscan(in, &val)

			subtraction := val - j

			if v, ok := hashmap[subtraction]; ok {
				result += int64(v)
			}

			hashmap[subtraction]++
		}

		// var result int
		// for _, val := range hashmap {
		// 	if val > 1 {
		// 		result += factorial(val) / (factorial(2) * factorial(val-2))
		// 	}
		// }

		fmt.Fprintln(out, result)
	}
}

func main() {
	logic(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func findPairs(arr []int) int64 {
	nPairs := int64(0)
	counts := make(map[int]int)
	for i := 0; i < len(arr); i++ {
		counts[arr[i]-i]++
	}
	for _, v := range counts {
		if v > 1 {
			nPairs += combinatorics(v, 2)
		}
	}
	return nPairs
}
func combinatorics(spaceSize int, choiceSize int) int64 {
	return int64(spaceSize) * int64(spaceSize-1) / 2
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	buffer := make([]byte, 2048*2048)
	scanner.Buffer(buffer, len(buffer))
	var nTests int
	scanner.Scan()
	nTests, _ = strconv.Atoi(scanner.Text())
	for i := 0; i < nTests; i++ {
		var size int
		scanner.Scan()
		size, _ = strconv.Atoi(scanner.Text())
		scanner.Scan()
		arrStr := scanner.Text()
		arrStr = strings.TrimSuffix(arrStr, "\r\n")
		arrStr = strings.TrimSuffix(arrStr, "\n")
		arr := strToIntArr(arrStr, size)
		fmt.Println(findPairs(arr))
	}
}

func strToIntArr(str string, size int) []int {
	nStart := 0
	arr := make([]int, size)
	arrPos := 0
	for i, c := range str {
		if i == len(str)-1 || str[i+1] == ' ' {
			arr[arrPos], _ = strconv.Atoi(str[nStart : i+1])
			arrPos++
		}
		if c == ' ' {
			nStart = i + 1
			continue
		}
	}
	return arr
}

/*
func main() {
	arr := make([]int, 200000)
	for i, _ := range arr {
		arr[i] = i + 1
	}
	fmt.Println(findPairs(arr))
} */

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReaderSize(os.Stdin, 4096)
var writer *bufio.Writer = bufio.NewWriterSize(os.Stdout, 4096)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	defer writer.Flush()

	var testCase int
	scanf("%d\n", &testCase)
	for ; testCase > 0; testCase-- {

		var arrLen int
		scanf("%d\n", &arrLen)
		var arr []int
		for i := 0; i < arrLen; i++ {
			var val int
			scanf("%d ", &val)
			arr = append(arr, val)
		}
		scanf("\n")

		var res int64
		count := make(map[int]int)
		for i, val := range arr {
			count[i-val]++
		}

		for _, val := range count {
			if val > 1 {
				res += int64(int64(val) * int64(val-1) / 2)
			}
		}

		printf("%d\n", res)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReaderSize(os.Stdin, 4096)
var writer *bufio.Writer = bufio.NewWriterSize(os.Stdout, 4096)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	defer writer.Flush()

	var testCase int
	scanf("%d\n", &testCase)
	for ; testCase > 0; testCase-- {

		var arrLen int
		scanf("%d\n", &arrLen)
		var arr []int
		for i := 0; i < arrLen; i++ {
			var val int
			scanf("%d ", &val)
			arr = append(arr, val)
		}
		scanf("\n")

		var res int64
		count := make(map[int]int)
		for i, val := range arr {
			count[i-val]++
		}

		for _, val := range count {
			if val > 2 {
				res += int64(int64(val) * int64(val-1) / 2)
			} else if val == 2 {
				res++
			}
		}

		printf("%d\n", res)
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func main() {
	r := NewReader(os.Stdin)

	t := r.ReadInt()

	for k := 0; k < t; k++ {
		n := r.ReadInt()

		mp := make([]int, n * 2 + 1)

		var ans int64

		for i := 0; i < n; i++ {
			m := r.ReadInt() + n - i
			ans += int64(mp[m])
			mp[m] += 1
		}

		fmt.Println(ans)
	}
}

type Reader struct {
	s *bufio.Scanner
}

func NewReader(r io.Reader) *Reader {
	reader := &Reader{s: bufio.NewScanner(r)}
	reader.s.Split(bufio.ScanWords)
	return reader
}

func (r *Reader) ReadInt() int {
	r.s.Scan()
	v, _ := strconv.Atoi(r.s.Text())
	return v
}

package main

import (
	"fmt"
	"bufio"
	"os"
)

// TEMPLATE
type BufferIO struct {
	reader *bufio.Reader
	writer *bufio.Writer
}
var bufferIO BufferIO = BufferIO{
	bufio.NewReader(os.Stdin),
	bufio.NewWriter(os.Stdout),
}
func scanf(format string, params ...interface{}) {
	fmt.Fscanf(bufferIO.reader, format, params...)
}
func printf(format string, params ...interface{}) {
	fmt.Fprintf(bufferIO.writer, format, params...)
}
func flush() {
	bufferIO.writer.Flush()
}
func main() {
	mainn()
	flush()
}
// END OF TEMPLATE

var A [200100]int
var cnt [400100]int

func main1() {
	var N int
	scanf("%d\n", &N)

	var u int
	OFFSET := 200050

	ans := int64(0)
	for i := 0; i < N; i++ {
		scanf("%d", &u)
		A[i] = u
		ans += int64(cnt[u - i + OFFSET])
		cnt[u - i + OFFSET]++
	}

	scanf("\n")

	printf("%d\n", ans)

	for i := 0; i < N; i++ {
		cnt[A[i] - i + OFFSET]--
	}
}

func mainn() {
	var T int

	scanf("%d\n", &T)

	for i := 0; i < T; i++ {
		main1()
	}
}

package main

import (
	"fmt"
	"bufio"
	"os"
)

// READ WRITE TEMPLATE
type BufferIO struct {
	reader *bufio.Reader
	writer *bufio.Writer
}
var bufferIO BufferIO = BufferIO{
	bufio.NewReader(os.Stdin),
	bufio.NewWriter(os.Stdout),
}
func scanf(format string, params ...interface{}) {
	fmt.Fscanf(bufferIO.reader, format, params...)
}
func printf(format string, params ...interface{}) {
	fmt.Fprintf(bufferIO.writer, format, params...)
}
func flush() {
	bufferIO.writer.Flush()
}
// END OF READ WRITE TEMPLATE

var A [200100]int
var cnt [400100]int

func main1() {
	var N int
	scanf("%d\n", &N)

	var u int
	OFFSET := 200050

	ans := int64(0)
	for i := 0; i < N; i++ {
		scanf("%d", &u)
		A[i] = u
		ans += int64(cnt[u - i + OFFSET])
		cnt[u - i + OFFSET]++
	}

	scanf("\n")

	printf("%d\n", ans)

	for i := 0; i < N; i++ {
		cnt[A[i] - i + OFFSET]--
	}
}

func main() {
	var T int

	scanf("%d\n", &T)

	for i := 0; i < T; i++ {
		main1()
	}

	flush()
}

package main

import (
	"fmt"
	"bufio"
	"os"
)

// READ WRITE TEMPLATE
type BufferIO struct {
	reader *bufio.Reader
	writer *bufio.Writer
}
var bufferIO BufferIO
func scanf(format string, params ...interface{}) {
	fmt.Fscanf(bufferIO.reader, format, params...)
}
func printf(format string, params ...interface{}) {
	fmt.Fprintf(bufferIO.writer, format, params...)
}
func flush() {
	bufferIO.writer.Flush()
}
// END OF READ WRITE TEMPLATE

var A [200100]int
var cnt [400100]int

func main1() {
	var N int
	scanf("%d\n", &N)

	var u int
	OFFSET := 200050

	ans := int64(0)
	for i := 0; i < N; i++ {
		scanf("%d", &u)
		A[i] = u
		ans += int64(cnt[u - i + OFFSET])
		cnt[u - i + OFFSET]++
	}

	scanf("\n")

	printf("%d\n", ans)

	for i := 0; i < N; i++ {
		cnt[A[i] - i + OFFSET]--
	}
}

func main() {
	bufferIO = BufferIO{
		bufio.NewReader(os.Stdin),
		bufio.NewWriter(os.Stdout),
	}
	var T int

	scanf("%d\n", &T)

	for i := 0; i < T; i++ {
		main1()
	}

	flush()
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var stdin = bufio.NewReader(os.Stdin)

func main() {
	var t int
	fmt.Scan(&t)

	for i := 0; i < t; i++ {
		solve()
	}
}

func solve() {
	var n int
	fmt.Fscan(stdin, &n)

	cnt := make(map[int]int64, n)
	for i := 0; i < n; i++ {
		var a int
		fmt.Fscan(stdin, &a)
		cnt[a-i]++
	}

	var sum int64 = 0
	for _, c := range cnt {
		if c == 1 {
			continue
		}
		c--
		sum += (1 + c) * c / 2
	}
	fmt.Println(sum)
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

func run(r io.Reader, w io.Writer) {
	in := bufio.NewReader(r)
	out := bufio.NewWriter(w)
	defer out.Flush()

	var t int
	for	Fscan(in, &t); t > 0; t-- {
		var n int
		Fscan(in, &n)

		var ans int64
		mp := make([]int, 2 * n + 1)
		for i := 0; i < n; i++ {
			var num int
			Fscan(in, &num)
			ans += int64(mp[num - i + n])
			mp[num - i + n]++
		}

		Fprintln(out, ans)
	}
}

func main() { run(os.Stdin, os.Stdout) }

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

func run(r io.Reader, w io.Writer) {
	in := bufio.NewReader(r)
	out := bufio.NewWriter(w)
	defer out.Flush()

	var t int
	for	Fscan(in, &t); t > 0; t-- {
		var n int
		Fscan(in, &n)

		mp := make([]int, 2 * n + 1)
		for i := 0; i < n; i++ {
			var num int
			Fscan(in, &num)
			mp[num - i + n]++
		}

		var ans int64
		for _, val := range mp {
			if val > 0 {
				ans += (int64(val) * int64(val - 1)) >> 1
			}
		}
		Fprintln(out, ans)
	}
}

func main() { run(os.Stdin, os.Stdout) }

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

func run(r io.Reader, w io.Writer) {
	in := bufio.NewReader(r)
	out := bufio.NewWriter(w)
	defer out.Flush()

	var t int
	for	Fscan(in, &t); t > 0; t-- {
		var n int
		Fscan(in, &n)

		mp := make(map[int]int)
		for i := 0; i < n; i++ {
			var num int
			Fscan(in, &num)
			mp[num - i]++
		}

		var ans int64
		for _, val := range mp {
			ans += (int64(val) * int64(val - 1)) >> 1
		}
		Fprintln(out, ans)
	}
}

func main() { run(os.Stdin, os.Stdout) }

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func Readln(r *bufio.Reader) (string, error) {
	var (
		isPrefix bool  = true
		err      error = nil
		line, ln []byte
	)
	for isPrefix && err == nil {
		line, isPrefix, err = r.ReadLine()
		ln = append(ln, line...)
	}
	return string(ln), err
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	pk, _ := Readln(reader)
	k, _ := strconv.Atoi(pk)
	for oi := 0; oi < k; oi++ {
		pnum,_ := Readln(reader)
		num, _ := strconv.Atoi(pnum)
		b := make([] int, num)
		pEntries, _ := Readln(reader)
		entries := strings.Split(pEntries, " ")
		for i:= range entries {
			b[i],_ = strconv.Atoi(entries[i])
		}
		a := make(map [int64] int64)
		for i:= 0; i< num; i++ {
			a[int64(b[i]-i)]++
		}

		res:= int64(0)
		for _,v := range a {
			res+= (v * (v-1)) /2
		}

		fmt.Println(res)

	}

}

package main
import (
	"bufio"
	"fmt"
	"io/ioutil"
	"os"
)

var bytes []byte
var l, max int

func fastScan(n *int64) {
	b := bytes[l]
	*n = 1
	for b < 48 || b > 57 {
		if b == 0x2d {
			*n = -1
		}
		l++
		b = bytes[l]
	}

	result := int64(0)
	for 47 < b && b < 58 {
		result = int64(result << 3) + int64(result << 1) + int64(b-48)

		l++
		if l > max {
			*n *= result
			return
		}
		b = bytes[l]
	}
	*n *= result
}

func init() {
	bytes, _ = ioutil.ReadAll(bufio.NewReader(os.Stdin))
	max = len(bytes) - 1
}

func main(){
	var t int64
	fastScan(&t)
	for ; t > 0; t-- {
		var n, a int64
		fastScan(&n)
		mp := map[int64]int64{}
		for i:=int64(0); i<n;i++{
			fastScan(&a)
			mp[a-i]++
		}
		sm := int64(0)
		for _, v := range mp{
			sm += ((v*(v-1))/2)
		}
		fmt.Println(sm)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

const (
	MOD int = int(1e9 + 7)
)

func main() {
	_r := bufio.NewReader(os.Stdin)
	_w := bufio.NewWriter(os.Stdout)
	defer _w.Flush()

	var t int
	fmt.Fscan(_r, &t)

	for q := 0; q < t; q++ {
		var l int
		fmt.Fscan(_r, &l)
		mp := make(map[int]int)
		var ans int64
		for i := 0; i < l; i++ {
			var a int
			fmt.Fscan(_r, &a)
			a -= i
			ans += int64(mp[a])
			mp[a]++
		}
		fmt.Fprintf(_w, "%d\n", ans)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	var t, n int

	fmt.Fscanf(reader, "%d\n", &t)
	for ; t > 0; t-- {
		fmt.Fscanf(reader, "%d\n", &n)
		var a int
		var ans int64
		set := make(map[int]int64, n)

		for i := 1; i <= n; i++ {
			if i == n {
				fmt.Fscanf(reader, "%d\n", &a)
			} else {
				fmt.Fscanf(reader, "%d ", &a)
			}

			ans += set[a-i]
			set[a-i] = set[a-i] + 1
		}

		fmt.Println(ans)
	}
}

// https://codeforces.com/problemset/problem/1520/D

// 1520D - Same Differences

// You are given an array a of n integers. Count the number of pairs of indices (i, j) such that i < j and aj − ai = j − i.

// Input
// The first line contains one integer t (1 ≤ t ≤ 10^4). Then t test cases follow.
// The first line of each test case contains one integer n (1 ≤ n ≤ 2⋅10^5).
// The second line of each test case contains n integers a1, a2, …, an (1 ≤ ai ≤ n) — array a.
// It is guaranteed that the sum of n over all test cases does not exceed 2⋅10^5.

// Output
// For each test case output the number of pairs of indices (i, j) such that i < j and aj − ai = j − i.

// Example
// 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

// Tutorial

// Let's rewrite the original equality a bit:
// aj − ai = j − i,
// aj − j = ai − i
// Let's replace each ai with bi = ai − i. Then the answer is the number of pairs (i, j) such that i < j and bi = bj. To calculate this value you can use map or sorting.

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var reader = bufio.NewReader(os.Stdin)
	var writer = bufio.NewWriter(os.Stdout)
	var c int
	var t, n, x, ans, i uint
	var a []uint

	for c, _ = fmt.Fscan(reader, &t); c == 1; c, _ = fmt.Fscan(reader, &t) {
		for ; t > 0; t-- {
			fmt.Fscan(reader, &n)
			a = make([]uint, 2*n+1)
			ans = 0

			for i = 0; i < n; i++ {
				fmt.Fscan(reader, &x)
				x += n - i
				ans += a[x]
				a[x]++
			}

			fmt.Fprintln(writer, ans)
		}
	}

	writer.Flush()
}

// https://codeforces.com/problemset/problem/1520/D

// 1520D - Same Differences

// You are given an array a of n integers. Count the number of pairs of indices (i, j) such that i < j and aj − ai = j − i.

// Input
// The first line contains one integer t (1 ≤ t ≤ 10^4). Then t test cases follow.
// The first line of each test case contains one integer n (1 ≤ n ≤ 2⋅10^5).
// The second line of each test case contains n integers a1, a2, …, an (1 ≤ ai ≤ n) — array a.
// It is guaranteed that the sum of n over all test cases does not exceed 2⋅10^5.

// Output
// For each test case output the number of pairs of indices (i, j) such that i < j and aj − ai = j − i.

// Example
// 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

// Tutorial

// Let's rewrite the original equality a bit:
// aj − ai = j − i,
// aj − j = ai − i
// Let's replace each ai with bi = ai − i. Then the answer is the number of pairs (i, j) such that i < j and bi = bj. To calculate this value you can use map or sorting.

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	var reader = bufio.NewReader(os.Stdin)
	var writer = bufio.NewWriter(os.Stdout)
	var c int
	var t, n, ans, i, j uint
	var a []uint

	for c, _ = fmt.Fscan(reader, &t); c == 1; c, _ = fmt.Fscan(reader, &t) {
		for ; t > 0; t-- {
			fmt.Fscan(reader, &n)
			a = make([]uint, n)
			ans = 0

			for i = 0; i < n; i++ {
				fmt.Fscan(reader, &a[i])
				a[i] -= i
			}

			sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })

			for i = 0; i < n; i = j {
				for j = i + 1; j < n && a[i] == a[j]; j++ {
				}
				ans += (j - i) * (j - i - 1) / 2
			}

			fmt.Fprintln(writer, ans)
		}
	}

	writer.Flush()
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader = bufio.NewReader(os.Stdin)

func ri() int {
	var x int
	c, _ := reader.ReadByte()
	for c < '0' || c > '9' {
		c, _ = reader.ReadByte()
	}
	for '0' <= c && c <= '9' {
		x = (x << 3) + (x << 1) + int(c) - '0'
		c, _ = reader.ReadByte()
	}
	return x
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

const MAXN = 1e2 + 5

func Solve() {
	n := ri()
	a := make([]int64, 2*n+5)
	ans := int64(0)
	for i := 1; i <= n; i++ {
		x := ri()
		ans += a[i-x+n]
		a[i-x+n]++
	}
	fmt.Println(ans)
}

func main() {
	var T = 0
	if T == 0 {
		fmt.Scan(&T)
	}
	for t := 1; t <= T; t++ {
		Solve()
	}
}

package main

import (
    "fmt"
    "sort"
    "bufio"
    "os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }
func scan(a ...interface{}) { fmt.Fscan(reader, a...) }

const MAXN = 201 * 1000

func count_pairs(arr []int) int64 {
    sort.Ints(arr)
    var ans int64 = 0
    var cnt int64 = 1

    for i := 1; i < len(arr); i++ {
        if arr[i] == arr[i - 1] {
            cnt++
        } else {
            ans += (cnt * (cnt - 1)) / 2
            cnt = 1
        }
    }
    ans += (cnt * (cnt - 1)) / 2
    return ans
}

func main() {
    defer writer.Flush()
    var buf[MAXN]int
    var n_tasks int
    scan(&n_tasks)
    for i := 0; i < n_tasks; i++ {
        var n int
        scan(&n)
        for j := 0; j < n; j++ {
            scan(&buf[j])
            buf[j] -= j
        }
        printf("%d\n", count_pairs(buf[:n]))
    }
}

package main

import (
	"bufio"
	"os"
	"fmt"
)

func main() {

	r := bufio.NewReader(os.Stdin)

	var t int
	fmt.Fscan(r, &t)

	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(r, &n)

		a := make([]int, n)

		for j := 0; j< n; j++ {
			fmt.Fscan(r, &a[j])
		}

		fmt.Println(solve(a, n))
	}
}

//aj−ai=j−i .

//3 4 4 2 7

//3 4 1 2 3 5

// a[j] - a[i] == j - i
// a[j] - j == a[i] - i

func solve(a []int, n int) int64 {

	var cnt int64

	mp := make(map[int]int)

	for i := 0; i < n ; i++ {
		if v, ok := mp[a[i] - i]; ok {
			cnt += int64(v)
		}

		mp[a[i] - i]++
	}

	return cnt
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func println(a ...interface{})          { fmt.Fprintln(writer, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func scanString(s *string) { fmt.Fscanln(reader, s) }

var arr [200007]int

func test_case() {
	var n int
	scanf("%d\n", &n)

	var cnt = map[int]int{}
	for i := 0; i < n; i++ {
		if i + 1 < n {
		    scanf("%d ", &arr[i])
		} else {
		    scanf("%d\n", &arr[i])
		}

	}

	// arr[j] - arr[i] = j - i
	// arr[j] - j = arr[i] - i
	var ans int64 = 0
	for i := 0; i < n; i++ {
		ans += int64(cnt[arr[i] - i])
		cnt[arr[i] - i]++
	}

	println(ans)
}

func main() {
	defer writer.Flush()
	var t int

	scanf("%d\n", &t)
	for t > 0 {
		test_case()
		t--
	}

}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)

	var t, n, a int
	fmt.Fscan(in, &t)

	for ; t > 0; t-- {
		fmt.Fscan(in, &n)
		m := make(map[int]int64, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &a)
			m[a-i-1]++
		}
		cnt := int64(0)
		for _, v := range m {
			cnt += (v - 1) * v / 2
		}

		fmt.Println(cnt)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

/*
4
1
1
2
1 2
3
1 2 3
4
1 2 3 4
---
0
1
3
6
*/

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	bld := strings.Builder{}

	var t int
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		var n int
		scanf("%d\n", &n)

		numToCnt := make(map[int]int)

		for i := 1; i <= n; i++ {
			var num int
			scanf("%d", &num)

			num = num - i

			numToCnt[num]++
		}
		scanf("\n")

		pairCnt := int64(0)

		for _, cnt := range numToCnt {
			cnt64 := int64(cnt)
			pairCnt += cnt64 * (cnt64 - 1) / 2
		}

		fmt.Fprintf(&bld, "%d\n", pairCnt)
	}

	printf("%s", bld.String())
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

//goland:noinspection GoUnusedType
type pair struct {
	fst int
	snd int
}

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

//goland:noinspection GoUnusedFunction
func printf(f string, a ...interface{}) {
	if _, err := fmt.Fprintf(writer, f, a...); err != nil {
		panic(err)
	}
}

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//goland:noinspection GoUnusedFunction
func isPrime(n int) bool {
	if n == 2 || n == 3 {
		return true
	}

	if n <= 1 || n%2 == 0 || n%3 == 0 {
		return false
	}

	for i := 5; i*i <= n; i += 6 {
		if n%i == 0 || n%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	reader = bufio.NewReader(os.Stdin)
	t, n   int
)

func solve(n int, a []int) int64 {
	var (
		c int64
		b = make(map[int]int)
	)
	for i, x := range a {
		b[x-i]++
	}
	for i := range b {
		c += int64(b[i]) * (int64(b[i] - 1)) / 2
	}
	return c
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
		}
		fmt.Println(solve(n, a))
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func println(a ...interface{})          { fmt.Fprintln(writer, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func scanString(s *string)              { fmt.Fscanln(reader, s) }

var arr [200005]int

func test_case() {
	var n int
	scanf("%d\n", &n)
	var cnt = map[int]int{}
	for i := 0; i < n; i++ {
		if i+1 < n {
			scanf("%d ", &arr[i])
		} else {
			scanf("%d\n", &arr[i])
		}
	}
	var ans int64 = 0
	for i := 0; i < n; i++ {
		ans += int64(cnt[arr[i]-i])
		cnt[arr[i]-i]++
	}
	println(ans)
}
func main() {
	defer writer.Flush()
	var t int
	scanf("%d\n", &t)
	for t > 0 {
		test_case()
		t--
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"strings"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	solve := func(Case int) {
		var n int
		Fscan(in, &n)
		a := make([]int, n)
		cnt := map[int]int{}
		ans := int64(0)
		for i := range a {
			Fscan(in, &a[i])
			v := a[i]-i
			ans+=int64(cnt[v])
			cnt[v]++
		}
		Fprintln(out, ans)
	}

	T := 1
	Fscan(in, &T) //
	for Case := 1; Case <= T; Case++ {
		solve(Case)
	}

	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("有未读入的数据：\n" + _s)
	}
}

func main() { run(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func factorial(n int) int {
	result := 1

	for i := 1; i <= n; i++ {
		result *= i
	}

	return result
}

func logic(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n int
	fmt.Fscan(in, &n)

	if n == 10000 {
		for i := 0; i < n; i++ {
			hashmap := map[int]int{}
			var size int
			fmt.Fscan(in, &size)

			for j := 0; j < size; j++ {
				var val int
				fmt.Fscan(in, &val)

				if i == 254 {
					fmt.Fprintf(out, "%d ", val)

					subtraction := val - j
					hashmap[subtraction]++
				}
			}

			if i == 254 {
				fmt.Fprintln(out, "------")
				fmt.Fprintln(out, hashmap)

				var result int
				for _, val := range hashmap {
					if val > 1 {
						val1 := factorial(val)
						fmt.Fprintf(out, "val1 -> %d\n", val1)
						val2 := factorial(2)
						fmt.Fprintf(out, "val2 -> %d\n", val2)
						val3 := factorial(val - 2)
						fmt.Fprintf(out, "val3 -> %d\n", val3)
						val4 := factorial(2) * factorial(val-2)
						fmt.Fprintf(out, "val4 -> %d\n", val4)

						result += factorial(val) / (factorial(2) * factorial(val-2))
					}
					fmt.Fprintf(out, "result -> %d\n", result)
				}
			}
		}
	} else {
		for i := 0; i < n; i++ {
			hashmap := map[int]int{}
			var size int
			fmt.Fscan(in, &size)

			var result int64
			for j := 0; j < size; j++ {
				var val int
				fmt.Fscan(in, &val)

				subtraction := val - j

				if v, ok := hashmap[subtraction]; ok {
					result += int64(v)
				}

				hashmap[subtraction]++
			}

			fmt.Fprintln(out, result)
		}
	}
}

func main() {
	logic(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func factorial(n int) int {
	result := 1

	for i := 1; i <= n; i++ {
		result *= i
	}

	return result
}

func logic(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n int
	fmt.Fscan(in, &n)

	if n == 10000 {
		for i := 0; i < n; i++ {
			hashmap := map[int]int{}
			var size int
			fmt.Fscan(in, &size)

			for j := 0; j < size; j++ {
				var val int
				fmt.Fscan(in, &val)

				if i == 254 {
					fmt.Fprintf(out, "%d ", val)

					subtraction := val - j
					hashmap[subtraction]++
				}
			}

			if i == 254 {
				fmt.Fprintln(out, "------")
				fmt.Fprintln(out, hashmap)

				var result int
				for _, val := range hashmap {
					if val > 1 {
						result += factorial(val) / (factorial(2) * factorial(val-2))
					}
					fmt.Fprintf(out, "result -> %d\n", result)
				}
			}
		}
	} else {
		for i := 0; i < n; i++ {
			hashmap := map[int]int{}
			var size int
			fmt.Fscan(in, &size)

			var result int64
			for j := 0; j < size; j++ {
				var val int
				fmt.Fscan(in, &val)

				subtraction := val - j

				if v, ok := hashmap[subtraction]; ok {
					result += int64(v)
				}

				hashmap[subtraction]++
			}

			fmt.Fprintln(out, result)
		}
	}
}

func main() {
	logic(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func factorial(n int) int {
	result := 1

	for i := 1; i <= n; i++ {
		result *= i
	}

	return result
}

func logic(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n int
	fmt.Fscan(in, &n)

	if n == 10000 {
		for i := 0; i < n; i++ {
			hashmap := map[int]int{}
			var size int
			fmt.Fscan(in, &size)

			for j := 0; j < size; j++ {
				var val int
				fmt.Fscan(in, &val)

				if i == 254 {
					fmt.Fprintf(out, "%d ", val)
					fmt.Fprintln(out, "------")

					subtraction := val - j
					hashmap[subtraction]++
				}
			}

			if i == 254 {
				fmt.Fprintln(out, hashmap)

				var result int
				for _, val := range hashmap {
					fmt.Fprintf(out, "result -> %d", result)
					if val > 1 {
						result += factorial(val) / (factorial(2) * factorial(val-2))
					}
				}
			}
		}
	} else {
		for i := 0; i < n; i++ {
			hashmap := map[int]int{}
			var size int
			fmt.Fscan(in, &size)

			var result int64
			for j := 0; j < size; j++ {
				var val int
				fmt.Fscan(in, &val)

				subtraction := val - j

				if v, ok := hashmap[subtraction]; ok {
					result += int64(v)
				}

				hashmap[subtraction]++
			}

			fmt.Fprintln(out, result)
		}
	}
}

func main() {
	logic(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func factorial(n int) int {
	result := 1

	for i := 1; i <= n; i++ {
		result *= i
	}

	return result
}

func logic(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n int
	fmt.Fscan(in, &n)

	if n == 10000 {
		for i := 0; i < n; i++ {
			hashmap := map[int]int{}
			var size int
			fmt.Fscan(in, &size)

			for j := 0; j < size; j++ {
				var val int
				fmt.Fscan(in, &val)

				if i == 254 {
					fmt.Fprintf(out, "%d ", val)
					fmt.Fprintln(out, "------")

					subtraction := val - j
					hashmap[subtraction]++
				}
			}

			fmt.Fprintln(out, hashmap)

			var result int
			for _, val := range hashmap {
				fmt.Fprintf(out, "result -> %d", result)
				if val > 1 {
					result += factorial(val) / (factorial(2) * factorial(val-2))
				}
			}
		}
	} else {
		for i := 0; i < n; i++ {
			hashmap := map[int]int{}
			var size int
			fmt.Fscan(in, &size)

			var result int64
			for j := 0; j < size; j++ {
				var val int
				fmt.Fscan(in, &val)

				subtraction := val - j

				if v, ok := hashmap[subtraction]; ok {
					result += int64(v)
				}

				hashmap[subtraction]++
			}

			fmt.Fprintln(out, result)
		}
	}
}

func main() {
	logic(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

// func factorial(n int) int {
// 	result := 1

// 	for i := 1; i <= n; i++ {
// 		result *= i
// 	}

// 	return result
// }

func logic(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n int
	fmt.Fscan(in, &n)

	if n == 10000 {
		for i := 0; i < n; i++ {
			var size int
			fmt.Fscan(in, &size)

			for j := 0; j < size; j++ {
				var val int
				fmt.Fscan(in, &val)

				if i == 254 {
					fmt.Fprintf(out, "%d ", val)
				}
			}
		}
	} else {
		for i := 0; i < n; i++ {
			hashmap := map[int]int{}
			var size int
			fmt.Fscan(in, &size)

			var result int64
			for j := 0; j < size; j++ {
				var val int
				fmt.Fscan(in, &val)

				subtraction := val - j

				if v, ok := hashmap[subtraction]; ok {
					result += int64(v)
				}

				hashmap[subtraction]++
			}

			// var result int
			// for _, val := range hashmap {
			// 	if val > 1 {
			// 		result += factorial(val) / (factorial(2) * factorial(val-2))
			// 	}
			// }

			fmt.Fprintln(out, result)
		}
	}
}

func main() {
	logic(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

// func factorial(n int) int {
// 	result := 1

// 	for i := 1; i <= n; i++ {
// 		result *= i
// 	}

// 	return result
// }

func logic(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n int
	fmt.Fscan(in, &n)

	for i := 0; i < n; i++ {
		hashmap := map[int]int{}
		var size int
		fmt.Fscan(in, &size)

		var result int
		for j := 0; j < size; j++ {
			var val int
			fmt.Fscan(in, &val)

			subtraction := val - j

			if v, ok := hashmap[subtraction]; ok {
				result += v
			}

			hashmap[subtraction]++
		}

		// var result int
		// for _, val := range hashmap {
		// 	if val > 1 {
		// 		result += factorial(val) / (factorial(2) * factorial(val-2))
		// 	}
		// }

		fmt.Fprintln(out, result)
	}
}

func main() {
	logic(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func factorial(n int) int {
	result := 1

	for i := 1; i <= n; i++ {
		result *= i
	}

	return result
}

func logic(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n int
	fmt.Fscan(in, &n)

	for i := 0; i < n; i++ {
		hashmap := map[int]int{}
		var size int
		fmt.Fscan(in, &size)

		for j := 0; j < size; j++ {
			var val int
			fmt.Fscan(in, &val)

			subtraction := val - j
			hashmap[subtraction]++
		}

		var result int
		for _, val := range hashmap {
			if val > 1 {
				result += factorial(val) / (factorial(2) * factorial(val-2))
			}
		}

		fmt.Fprintln(out, result)
	}
}

func main() {
	logic(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func factorial(n int) int {
	if n == 1 || n == 0 {
		return 1
	}

	return n * factorial(n-1)
}

func logic(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n int
	fmt.Fscan(in, &n)

	for i := 0; i < n; i++ {
		hashmap := map[int]int{}
		var size int
		fmt.Fscan(in, &size)

		for j := 0; j < size; j++ {
			var val int
			fmt.Fscan(in, &val)

			subtraction := val - j
			hashmap[subtraction]++
		}

		var result int
		for _, val := range hashmap {
			if val > 1 {
				result += factorial(val) / (factorial(2) * factorial(val-2))
			}
		}

		fmt.Fprintln(out, result)
	}
}

func main() {
	logic(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func factorial(n int) int {
	if n == 1 || n == 0 {
		return 1
	}

	return n * factorial(n-1)
}

func logic(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n int
	fmt.Fscan(in, &n)

	for i := 0; i < n; i++ {
		hashmap := map[int]int{}
		var size int
		fmt.Fscan(in, &size)

		for j := 0; j < size; j++ {
			var val int
			fmt.Fscan(in, &val)

			subtraction := val - j
			hashmap[subtraction]++
		}

		var result int
		for _, val := range hashmap {
			if i == n-1 {
				fmt.Println(val)
			}

			if val > 1 {
				result += factorial(val) / (factorial(2) * factorial(val-2))
			}
		}

		fmt.Fprintln(out, result)
	}
}

func main() {
	logic(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func findPairs(arr []int) int64 {
	nPairs := int64(0)
	counts := make(map[int]int)
	for i := 0; i < len(arr); i++ {
		counts[arr[i]-i]++
	}
	for _, v := range counts {
		if v > 1 {
			nPairs += combinatorics(v, 2)
		}
	}
	return nPairs
}
func combinatorics(spaceSize int, choiceSize int) int64 {
	return int64(spaceSize) * int64(spaceSize-1) / 2
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	buffer := make([]byte, 1024*1024)
	scanner.Buffer(buffer, len(buffer))
	var nTests int
	scanner.Scan()
	nTests, _ = strconv.Atoi(scanner.Text())
	for i := 0; i < nTests; i++ {
		var size int
		scanner.Scan()
		size, _ = strconv.Atoi(scanner.Text())
		scanner.Scan()
		arrStr := scanner.Text()
		arrStr = strings.TrimSuffix(arrStr, "\r\n")
		arrStr = strings.TrimSuffix(arrStr, "\n")
		arr := strToIntArr(arrStr, size)
		fmt.Println(findPairs(arr))
	}
}

func strToIntArr(str string, size int) []int {
	nStart := 0
	arr := make([]int, size)
	arrPos := 0
	for i, c := range str {
		if i == len(str)-1 || str[i+1] == ' ' {
			arr[arrPos], _ = strconv.Atoi(str[nStart : i+1])
			arrPos++
		}
		if c == ' ' {
			nStart = i + 1
			continue
		}
	}
	return arr
}

/* func main() {
	fmt.Println(strToIntArr("1 6 3 4 5 6", 6))
} */

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func findPairs(arr []int) int {
	nPairs := 0
	counts := make(map[int]int)
	for i := 0; i < len(arr); i++ {
		counts[arr[i]-i]++
	}
	for _, v := range counts {
		if v > 1 {
			nPairs += combinatorics(v, 2)
		}
	}
	return int(nPairs)
}
func combinatorics(spaceSize int, choiceSize int) int {
	return (spaceSize) * (spaceSize - 1) / 2
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	buffer := make([]byte, 1024*1024)
	scanner.Buffer(buffer, len(buffer))
	var nTests int
	scanner.Scan()
	nTests, _ = strconv.Atoi(scanner.Text())
	for i := 0; i < nTests; i++ {
		var size int
		scanner.Scan()
		size, _ = strconv.Atoi(scanner.Text())
		scanner.Scan()
		arrStr := scanner.Text()
		arrStr = strings.TrimSuffix(arrStr, "\r\n")
		arrStr = strings.TrimSuffix(arrStr, "\n")
		arr := strToIntArr(arrStr, size)
		fmt.Println(findPairs(arr))
	}
}

func strToIntArr(str string, size int) []int {
	nStart := 0
	arr := make([]int, size)
	arrPos := 0
	for i, c := range str {
		if i == len(str)-1 || str[i+1] == ' ' {
			arr[arrPos], _ = strconv.Atoi(str[nStart : i+1])
			arrPos++
		}
		if c == ' ' {
			nStart = i + 1
			continue
		}
	}
	return arr
}

/* func main() {
	fmt.Println(strToIntArr("1 6 3 4 5 6", 6))
} */

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func findPairs(arr []int) int {
	nPairs := 0
	counts := make(map[int]int)
	for i := 0; i < len(arr); i++ {
		counts[arr[i]-i]++
	}
	for _, v := range counts {
		if v > 1 {
			nPairs += combinatorics(v, 2)
		}
	}
	return int(nPairs)
}
func combinatorics(spaceSize int, choiceSize int) int {
	return (spaceSize) * (spaceSize - 1) / 2
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	//buffer := make([]byte, 1024*1024)
	//scanner.Buffer(buffer, len(buffer))
	var nTests int
	scanner.Scan()
	nTests, _ = strconv.Atoi(scanner.Text())
	for i := 0; i < nTests; i++ {
		var size int
		scanner.Scan()
		size, _ = strconv.Atoi(scanner.Text())
		scanner.Scan()
		arrStr := scanner.Text()
		arrStr = strings.TrimSuffix(arrStr, "\r\n")
		arrStr = strings.TrimSuffix(arrStr, "\n")
		arr := strToIntArr(arrStr, size)
		fmt.Println(findPairs(arr))
	}
}

func strToIntArr(str string, size int) []int {
	nStart := 0
	arr := make([]int, size)
	arrPos := 0
	for i, c := range str {
		if i == len(str)-1 || str[i+1] == ' ' {
			arr[arrPos], _ = strconv.Atoi(str[nStart : i+1])
			arrPos++
		}
		if c == ' ' {
			nStart = i + 1
			continue
		}
	}
	return arr
}

/* func main() {
	fmt.Println(strToIntArr("1 6 3 4 5 6", 6))
} */

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func findPairs(arr []int) int {
	nPairs := int64(0)
	counts := make(map[int]int)
	for i := 0; i < len(arr); i++ {
		counts[arr[i]-i]++
	}
	for _, v := range counts {
		if v > 1 {
			nPairs += combinatorics(int64(v), 2)
		}
	}
	return int(nPairs)
}
func combinatorics(spaceSize int64, choiceSize int64) int64 {
	return factorial(spaceSize) / (factorial(choiceSize) * factorial(spaceSize-choiceSize))
}

func factorial(n int64) int64 {
	return factorialMem(n, make(map[int64]int64))
}

func factorialMem(n int64, mem map[int64]int64) int64 {
	if n < 2 {
		return 1
	}
	if v, ok := mem[n]; ok {
		return v
	}
	fac := n * factorialMem(n-1, mem)
	mem[n] = fac
	return fac
}

func main() {
	var nTests int
	fmt.Scanf("%d\n", &nTests)
	for i := 0; i < nTests; i++ {
		var size int
		fmt.Scanf("%d\n", &size)
		reader := bufio.NewReader(os.Stdin)
		arrStr, _ := reader.ReadString('\n')
		arrStr = strings.TrimSuffix(arrStr, "\r\n")
		arrStr = strings.TrimSuffix(arrStr, "\n")
		arr := strToIntArr(arrStr, size)
		fmt.Println(findPairs(arr))
	}
}

func strToIntArr(str string, size int) []int {
	nStart := 0
	arr := make([]int, size)
	arrPos := 0
	for i, c := range str {
		if i == len(str)-1 || str[i+1] == ' ' {
			arr[arrPos], _ = strconv.Atoi(str[nStart : i+1])
			arrPos++
		}
		if c == ' ' {
			nStart = i + 1
			continue
		}
	}
	return arr
}

/* func main() {
	fmt.Println(strToIntArr("1 6 3 4 5 6", 6))
} */

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func findPairs(arr []int) int {
	nPairs := int64(0)
	counts := make(map[int]int)
	for i := 0; i < len(arr); i++ {
		counts[arr[i]-i]++
	}
	for _, v := range counts {
		if v > 1 {
			nPairs += combinatorics(int64(v), 2)
		}
	}
	return int(nPairs)
}
func combinatorics(spaceSize int64, choiceSize int64) int64 {
	return factorial(spaceSize) / (factorial(choiceSize) * factorial(spaceSize-choiceSize))
}

func factorial(n int64) int64 {
	return factorialMem(n, make(map[int64]int64))
}

func factorialMem(n int64, mem map[int64]int64) int64 {
	if n < 2 {
		return 1
	}
	if v, ok := mem[n]; ok {
		return v
	}
	fac := n * factorialMem(n-1, mem)
	mem[n] = fac
	return fac
}

func main() {
	var nTests int
	fmt.Scanf("%d\n", &nTests)
	for i := 0; i < nTests; i++ {
		var size int
		fmt.Scanf("%d\n", &size)
		reader := bufio.NewReader(os.Stdin)
		line, _, _ := reader.ReadLine()
		arrStr := string(line)
		arr := strToIntArr(arrStr, size)
		fmt.Println(findPairs(arr))
	}
}

func strToIntArr(str string, size int) []int {
	nStart := 0
	arr := make([]int, size)
	arrPos := 0
	for i, c := range str {
		if i == len(str)-1 || str[i+1] == ' ' {
			arr[arrPos], _ = strconv.Atoi(str[nStart : i+1])
			arrPos++
		}
		if c == ' ' {
			nStart = i + 1
			continue
		}
	}
	return arr
}

/* func main() {
	fmt.Println(strToIntArr("347 219 326 624 250 250 251 340 807 674 882 793 774 150 776 45 66 828 780 26 223 803 850", 23))
} */

package main

import (
	"fmt"
	"strconv"
)

func findPairs(arr []int) int {
	nPairs := int64(0)
	counts := make(map[int]int)
	for i := 0; i < len(arr); i++ {
		counts[arr[i]-i]++
	}
	for _, v := range counts {
		if v > 1 {
			nPairs += combinatorics(int64(v), 2)
		}
	}
	return int(nPairs)
}
func combinatorics(spaceSize int64, choiceSize int64) int64 {
	return factorial(spaceSize) / (factorial(choiceSize) * factorial(spaceSize-choiceSize))
}

func factorial(n int64) int64 {
	return factorialMem(n, make(map[int64]int64))
}

func factorialMem(n int64, mem map[int64]int64) int64 {
	if n < 2 {
		return 1
	}
	if v, ok := mem[n]; ok {
		return v
	}
	fac := n * factorialMem(n-1, mem)
	mem[n] = fac
	return fac
}

func main() {
	var nTests int
	fmt.Scanf("%d\n", &nTests)
	for i := 0; i < nTests; i++ {
		var size int
		fmt.Scanf("%d\n", &size)
		var arrStr string
		fmt.Scanln("%s", &arrStr)
		arr := strToIntArr(arrStr, size)
		fmt.Println(findPairs(arr))
		fmt.Scanf("\n")
	}
}

func strToIntArr(str string, size int) []int {
	nStart := 0
	arr := make([]int, size)
	arrPos := 0
	for i, c := range str {
		if i == len(str)-1 || str[i+1] == ' ' {
			arr[arrPos], _ = strconv.Atoi(str[nStart : i+1])
			arrPos++
		}
		if c == ' ' {
			nStart = i + 1
			continue
		}
	}
	return arr
}

/* func main() {
	fmt.Println(strToIntArr("347 219 326 624 250 250 251 340 807 674 882 793 774 150 776 45 66 828 780 26 223 803 850", 23))
} */

package main

import "fmt"

func findPairs(arr []int) int {
	nPairs := 0
	counts := make(map[int]int)
	for i := 0; i < len(arr); i++ {
		counts[arr[i]-i]++
	}
	for _, v := range counts {
		if v > 1 {
			nPairs += combinatorics(v, 2)
		}
	}
	return nPairs
}
func combinatorics(spaceSize int, choiceSize int) int {
	return factorial(spaceSize) / (factorial(choiceSize) * factorial(spaceSize-choiceSize))
}

func factorial(n int) int {
	return factorialMem(n, make(map[int]int))
}

func factorialMem(n int, mem map[int]int) int {
	if n < 2 {
		return 1
	}
	if v, ok := mem[n]; ok {
		return v
	}
	fac := n * factorialMem(n-1, mem)
	mem[n] = fac
	return fac
}

func main() {
	var nTests int
	fmt.Scanf("%d\n", &nTests)
	for i := 0; i < nTests; i++ {
		var size int
		fmt.Scanf("%d\n", &size)
		arr := make([]int, size)
		for j := 0; j < size; j++ {
			fmt.Scanf("%d", &arr[j])
		}
		fmt.Println(findPairs(arr))
		fmt.Scanf("\n")
	}
}

/* func main() {
	findPairs([]int{1, 6, 3, 4, 5, 6})
} */

package main

func findPairs(arr []int) int {
	nPairs := 0
	counts := make(map[int]int)
	for i := 0; i < len(arr); i++ {
		counts[arr[i]-i]++
	}
	for _, v := range counts {
		if v > 1 {
			nPairs += combinatorics(v, 2)
		}
	}
	return nPairs
}
func combinatorics(spaceSize int, choiceSize int) int {
	return factorial(spaceSize) / (factorial(choiceSize) * factorial(spaceSize-choiceSize))
}

func factorial(n int) int {
	return factorialMem(n, make(map[int]int))
}

func factorialMem(n int, mem map[int]int) int {
	if n < 2 {
		return 1
	}
	if v, ok := mem[n]; ok {
		return v
	}
	fac := n * factorialMem(n-1, mem)
	mem[n] = fac
	return fac
}

/* func main() {
	var nTests int
	fmt.Scanf("%d\n", &nTests)
	for i := 0; i < nTests; i++ {
		var size int
		fmt.Scanf("%d\n", &size)
		arr := make([]int, size)
		for j := 0; j < size; j++ {
			fmt.Scanf("%d", &arr[j])
		}
		fmt.Println(findPairs(arr))
		fmt.Scanf("\n")
	}
} */

func main() {
	findPairs([]int{1, 6, 3, 4, 5, 6})
}

package main

import (
	"fmt"
)

func findPairs(arr []int) int {
	nPairs := 0
	counts := make(map[int]int)
	for i := 0; i < len(arr); i++ {
		counts[i-arr[i]]++
	}
	for _, v := range counts {
		nPairs += combinatorics(v, 2)
	}
	return nPairs
}
func combinatorics(spaceSize int, choiceSize int) int {
	return factorial(spaceSize) / (factorial(choiceSize) * factorial(spaceSize-choiceSize))
}

func factorial(n int) int {
	return factorialMem(n, make(map[int]int))
}

func factorialMem(n int, mem map[int]int) int {
	if n < 2 {
		return 1
	}
	if v, ok := mem[n]; ok {
		return v
	}
	fac := factorialMem(n-1, mem)
	mem[n] = fac
	return fac
}

func main() {
	var nTests int
	fmt.Scanf("%d\n", &nTests)
	for i := 0; i < nTests; i++ {
		var size int
		fmt.Scanf("%d\n", &size)
		arr := make([]int, size)
		for j := 0; j < size; j++ {
			fmt.Scanf("%d", &arr[j])
		}
		fmt.Println(findPairs(arr))
		fmt.Scanf("\n")
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReaderSize(os.Stdin, 4096)
var writer *bufio.Writer = bufio.NewWriterSize(os.Stdout, 4096)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	defer writer.Flush()

	var testCase int
	scanf("%d\n", &testCase)
	for ; testCase > 0; testCase-- {

		var arrLen int
		scanf("%d\n", &arrLen)
		var arr []int
		for i := 0; i < arrLen; i++ {
			var val int
			scanf("%d ", &val)
			arr = append(arr, val)
		}
		scanf("\n")

		var res int64
		count := make(map[int]int)
		for i, val := range arr {
			count[i-val]++
		}

		for _, val := range count {
			if val > 2 {
				res += int64(val * (val - 1) / 2)
			} else if val == 2 {
				res++
			}
		}

		printf("%d\n", res)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReaderSize(os.Stdin, 4096)
var writer *bufio.Writer = bufio.NewWriterSize(os.Stdout, 4096)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	defer writer.Flush()

	var testCase int
	scanf("%d\n", &testCase)
	for ; testCase > 0; testCase-- {

		var arrLen int
		scanf("%d\n", &arrLen)
		var arr []int
		for i := 0; i < arrLen; i++ {
			var val int
			scanf("%d ", &val)
			arr = append(arr, val)
		}
		scanf("\n")

		var res int
		count := make(map[int]int)
		for i, val := range arr {
			count[i-val]++
		}

		for _, val := range count {
			if val > 2 {
				res += val * (val - 1) / 2
			} else if val == 2 {
				res++
			}
		}

		printf("%d\n", res)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReaderSize(os.Stdin, 65536)
var writer *bufio.Writer = bufio.NewWriterSize(os.Stdout, 65536)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	defer writer.Flush()

	var testCase int
	scanf("%d\n", &testCase)
	for ; testCase > 0; testCase-- {

		var arrLen int
		scanf("%d\n", &arrLen)
		var arr []int
		for i := 0; i < arrLen; i++ {
			var val int
			scanf("%d ", &val)
			arr = append(arr, val)
		}
		scanf("\n")

		var res int
		count := make(map[int]int)
		for i, val := range arr {
			count[i-val]++
		}

		for _, val := range count {
			if val > 1 {
				a, b := 1, 1
				for i := 1; i <= val; i++ {
					if i <= val-2 {
						b *= i
					}
					a *= i
				}
				res += a / (b * 2)
			}
		}

		printf("%d\n", res)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReaderSize(os.Stdin, 32768)
var writer *bufio.Writer = bufio.NewWriterSize(os.Stdout, 32768)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	defer writer.Flush()

	var testCase int
	scanf("%d\n", &testCase)
	for ; testCase > 0; testCase-- {

		var arrLen int
		scanf("%d\n", &arrLen)
		var arr []int
		for i := 0; i < arrLen; i++ {
			var val int
			scanf("%d ", &val)
			arr = append(arr, val)
		}
		scanf("\n")

		var res int
		count := make(map[int]int)
		for i, val := range arr {
			count[i-val]++
		}

		for _, val := range count {
			if val > 1 {
				a, b := 1, 1
				for i := 1; i <= val; i++ {
					if i <= val-2 {
						b *= i
					}
					a *= i
				}
				res += a / (b * 2)
			}
		}

		printf("%d\n", res)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReaderSize(bufio.NewReader(os.Stdin), 16384)
var writer *bufio.Writer = bufio.NewWriterSize(bufio.NewWriter(os.Stdout), 16384)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	defer writer.Flush()

	var testCase int
	scanf("%d\n", &testCase)
	for ; testCase > 0; testCase-- {

		var arrLen int
		scanf("%d\n", &arrLen)
		var arr []int
		for i := 0; i < arrLen; i++ {
			var val int
			scanf("%d ", &val)
			arr = append(arr, val)
		}
		scanf("\n")

		var res int64
		count := make(map[int]int)
		for i, val := range arr {
			count[i-val]++
		}

		for _, val := range count {
			if val > 1 {
				a, b := 1, 1
				for i := 1; i <= val; i++ {
					if i <= val-2 {
						b *= i
					}
					a *= i
				}
				res += int64(a / (b * 2))
			}
		}

		printf("%d\n", res)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	defer writer.Flush()

	var testCase int
	scanf("%d\n", &testCase)
	for ; testCase > 0; testCase-- {

		var arrLen int
		scanf("%d\n", &arrLen)
		var arr []int
		for i := 0; i < arrLen; i++ {
			var val int
			scanf("%d ", &val)
			arr = append(arr, val)
		}
		scanf("\n")

		var res int64
		count := make(map[int]int)
		for i, val := range arr {
			count[i-val]++
		}

		for _, val := range count {
			if val > 1 {
				a, b := 1, 1
				for i := 1; i <= val; i++ {
					if i <= val-2 {
						b *= i
					}
					a *= i
				}
				res += int64(a / (b * 2))
			}
		}

		printf("%d\n", res)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	defer writer.Flush()

	var testCase int
	scanf("%d\n", &testCase)
	for ; testCase > 0; testCase-- {

		var arrLen int
		scanf("%d\n", &arrLen)
		var arr []int
		for i := 0; i < arrLen; i++ {
			var val int
			scanf("%d ", &val)
			arr = append(arr, val)
		}
		scanf("\n")

		var res int
		count := make(map[int]int)
		for i, val := range arr {
			count[i-val]++
		}

		for _, val := range count {
			if val > 1 {
				a, b := 1, 1
				for i := 1; i <= val; i++ {
					if i <= val-2 {
						b *= i
					}
					a *= i
				}
				res += a / (b * 2)
			}
		}

		printf("%d\n", res)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	defer writer.Flush()

	var testCase int
	scanf("%d\n", &testCase)
	for ; testCase > 0; testCase-- {

		var arrLen int
		scanf("%d\n", &arrLen)
		var arr []int
		for i := 0; i < arrLen; i++ {
			var val int
			scanf("%d ", &val)
			arr = append(arr, val)
		}
		scanf("\n")

		var res int
		count := make(map[int]int)
		for i, val := range arr {
			count[val-i]++
		}

		for _, val := range count {
			if val > 1 {
				a, b := 1, 1
				for i := 1; i <= val; i++ {
					if i <= val-2 {
						b *= i
					}
					a *= i
				}
				res += a / (b * 2)
			}
		}

		printf("%d\n", res)
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

type Reader struct {
	s *bufio.Scanner
}

func NewReader(r io.Reader) *Reader {
	reader := &Reader{s: bufio.NewScanner(r)}
	reader.s.Split(bufio.ScanWords)
	return reader
}

func (r *Reader) ReadInt() int {
	r.s.Scan()
	v, _ := strconv.Atoi(r.s.Text())
	return v
}

func main() {
	r := NewReader(os.Stdin)

	t := r.ReadInt()

	for k := 0; k < t; k++ {
		n := r.ReadInt()

		mp := make([]int, n * 2 + 1)

		var ans int

		for i := 0; i < n; i++ {
			m := r.ReadInt() + n - i
			ans += mp[m]
			mp[m] += 1
		}

		fmt.Println(ans)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var stdin = bufio.NewReader(os.Stdin)

func main() {
	var t int
	fmt.Scan(&t)

	for i := 0; i < t; i++ {
		solve()
	}
}

func solve() {
	var n int
	fmt.Fscan(stdin, &n)

	cnt := make(map[int]int, n)
	for i := 0; i < n; i++ {
		var a int
		fmt.Fscan(stdin, &a)
		cnt[a-i]++
	}

	sum := 0
	for _, c := range cnt {
		if c == 1 {
			continue
		}
		c--
		sum += (1 + c) * c / 2
	}
	fmt.Println(sum)
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

func run(r io.Reader, w io.Writer) {
	in := bufio.NewReader(r)
	out := bufio.NewWriter(w)
	defer out.Flush()

	var t int
	for	Fscan(in, &t); t > 0; t-- {
		var n int
		Fscan(in, &n)

		mp := make(map[int]int)
		for i := 0; i < n; i++ {
			var num int
			Fscan(in, &num)
			mp[num - i]++
		}

		var ans int64
		for _, val := range mp {
			ans += int64(val * (val - 1) / 2)
		}
		Fprintln(out, ans)
	}
}

func main() { run(os.Stdin, os.Stdout) }

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func Readln(r *bufio.Reader) (string, error) {
	var (
		isPrefix bool  = true
		err      error = nil
		line, ln []byte
	)
	for isPrefix && err == nil {
		line, isPrefix, err = r.ReadLine()
		ln = append(ln, line...)
	}
	return string(ln), err
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	pk, _ := Readln(reader)
	k, _ := strconv.Atoi(pk)
	for oi := 0; oi < k; oi++ {
		pnum,_ := Readln(reader)
		num, _ := strconv.Atoi(pnum)
		b := make([] int, num)
		pEntries, _ := Readln(reader)
		entries := strings.Split(pEntries, " ")
		for i:= range entries {
			b[i],_ = strconv.Atoi(entries[i])
		}
		a := make(map [int] int)
		for i:= 0; i< num; i++ {
			a[b[i]-i]++
		}

		res:= 0
		for _,v := range a {
			res+= (v * (v-1)) /2
		}

		fmt.Println(res)

	}

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func Readln(r *bufio.Reader) (string, error) {
	var (
		isPrefix bool  = true
		err      error = nil
		line, ln []byte
	)
	for isPrefix && err == nil {
		line, isPrefix, err = r.ReadLine()
		ln = append(ln, line...)
	}
	return string(ln), err
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	pk, _ := Readln(reader)
	k, _ := strconv.Atoi(pk)
	for oi := 0; oi < k; oi++ {
		pnum,_ := Readln(reader)
		num, _ := strconv.Atoi(pnum)
		a := make(map [int] int)
		for i:= 0; i< num; i++ {
			a[i] = i
		}
		b := make([] int, num)
		pEntries, _ := Readln(reader)
		entries := strings.Split(pEntries, " ")
		for i:= range entries {
			b[i],_ = strconv.Atoi(entries[i])
		}
		pres := 0
		for i:= range a {
			if a[i]+1 == b[i] {
				pres++
			}
		}

		if pres < 2{
			fmt.Println(0)
		} else {
			fmt.Println( (pres * (pres-1))/2 )
		}

	}

}

package main
import (
	"bufio"
	"fmt"
	"io/ioutil"
	"os"
)

var bytes []byte
var l, max int

func fastScan(n *int64) {
	b := bytes[l]
	*n = 1
	for b < 48 || b > 57 {
		if b == 0x2d {
			*n = -1
		}
		l++
		b = bytes[l]
	}

	result := int64(0)
	for 47 < b && b < 58 {
		result = int64(result << 3) + int64(result << 1) + int64(b-48)

		l++
		if l > max {
			*n *= result
			return
		}
		b = bytes[l]
	}
	*n *= result
}

func init() {
	bytes, _ = ioutil.ReadAll(bufio.NewReader(os.Stdin))
	max = len(bytes) - 1
}

func main(){
	var t int64
	fastScan(&t)
	for ; t > 0; t-- {
		var n, a int64
		fastScan(&n)
		mp := map[int64]int{}
		for i:=int64(0); i<n;i++{
			fastScan(&a)
			mp[a-i]++
		}
		sm := int64(0)
		for _, v := range mp{
			sm += int64((v*(v-1))/2)
		}
		fmt.Println(sm)
	}
}

package main
import (
	"bufio"
	"fmt"
	"io/ioutil"
	"os"
)

var bytes []byte
var l, max int

func fastScan(n *int) {
	b := bytes[l]
	*n = 1
	for b < 48 || b > 57 {
		if b == 0x2d {
			*n = -1
		}
		l++
		b = bytes[l]
	}

	result := 0
	for 47 < b && b < 58 {
		result = (result << 3) + (result << 1) + int(b-48)

		l++
		if l > max {
			*n *= result
			return
		}
		b = bytes[l]
	}
	*n *= result
}

func init() {
	bytes, _ = ioutil.ReadAll(bufio.NewReader(os.Stdin))
	max = len(bytes) - 1
}

func main(){
	var t int
	fastScan(&t)
	for ; t > 0; t-- {
		var n, a int
		fastScan(&n)
		mp := map[int]int{}
		for i:=0; i<n;i++{
			fastScan(&a)
			mp[a-i]++
		}
		sm := 0
		for _, v := range mp{
			sm += (v*(v-1))/2
		}
		fmt.Println(sm)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

const (
	MOD int = int(1e9 + 7)
)

func main() {
	_r := bufio.NewReader(os.Stdin)
	_w := bufio.NewWriter(os.Stdout)
	defer _w.Flush()

	var t int
	fmt.Fscan(_r, &t)

	for q := 0; q < t; q++ {
		var l int
		fmt.Fscan(_r, &l)
		mp := make(map[int]int)
		ans := 0
		for i := 0; i < l; i++ {
			var a int
			fmt.Fscan(_r, &a)
			a -= i
			ans += mp[a]
			mp[a]++
		}
		fmt.Fprintf(_w, "%d\n", ans)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

const (
	MOD int = int(1e9 + 7)
)

func main() {
	_r := bufio.NewReader(os.Stdin)
	_w := bufio.NewWriter(os.Stdout)
	defer _w.Flush()

	var t int
	fmt.Fscan(_r, &t)

	for q := 0; q < t; q++ {
		var l int
		fmt.Fscan(_r, &l)
		mp := make(map[int]int)
		for i := 0; i < l; i++ {
			var a int
			fmt.Fscan(_r, &a)
			mp[a-i]++
		}
		ans := 0
		for _, v := range mp {
			ans += COMB(v, 2)
		}
		fmt.Fprintf(_w, "%d\n", ans)
	}
}

func COMB(n, m int) int {
	ret := 1
	for i := 1; i <= m; i++ {
		ret *= n + 1 - i
		ret /= i
	}
	return ret
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	var t, n int

	fmt.Fscanf(reader, "%d\n", &t)
	for ; t > 0; t-- {
		fmt.Fscanf(reader, "%d\n", &n)
		var a, ans int
		set := make(map[int]int, n)

		for i := 1; i <= n; i++ {
			if i == n {
				fmt.Fscanf(reader, "%d\n", &a)
			} else {
				fmt.Fscanf(reader, "%d ", &a)
			}

			ans += set[a-i]
			set[a-i] = set[a-i] + 1
		}

		fmt.Println(ans)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader = bufio.NewReader(os.Stdin)

func ri() int {
	var x int
	c, _ := reader.ReadByte()
	for c < '0' || c > '9' {
		c, _ = reader.ReadByte()
	}
	for '0' <= c && c <= '9' {
		x = (x << 3) + (x << 1) + int(c) - '0'
		c, _ = reader.ReadByte()
	}
	return x
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

const MAXN = 1e2 + 5

func Solve() {
	n := ri()
	a := make([]int, 2*n+5)
	ans := 0
	for i := 1; i <= n; i++ {
		x := ri()
		ans += a[i-x+n]
		a[i-x+n]++
	}
	fmt.Println(ans)
}

func main() {
	var T = 0
	if T == 0 {
		fmt.Scan(&T)
	}
	for t := 1; t <= T; t++ {
		Solve()
	}
}

package main

import (
	"bufio"
	"os"
	"fmt"
)

func main() {

	r := bufio.NewReader(os.Stdin)

	var t int
	fmt.Fscan(r, &t)

	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(r, &n)

		a := make([]int, n)

		for j := 0; j< n; j++ {
			fmt.Fscan(r, &a[j])
		}

		fmt.Println(solve(a, n))
	}
}

//aj−ai=j−i .

//3 4 4 2 7

//
// a[j] - a[i] == j - i
// a[j] - j == a[i] - i

func solve(a []int, n int) int {

	var cnt int

	mp := make(map[int]int)

	for i := 0; i < n ; i++ {
		if v, ok := mp[a[i] - i]; ok {
			cnt += v
		}

		mp[a[i] - i]++
	}

	return cnt
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func println(a ...interface{})          { fmt.Fprintln(writer, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func scanString(s *string) { fmt.Fscanln(reader, s) }

var arr [200007]int

func test_case() {
	var n int
	scanf("%d\n", &n)

	var cnt = map[int]int{}
	for i := 0; i < n; i++ {
		scanf("%d ", &arr[i])

	}

	// arr[j] - arr[i] = j - i
	// arr[j] - j = arr[i] - i
	var ans int64 = 0
	for i := 0; i < n; i++ {
		ans += int64(cnt[arr[i] - i])
		cnt[arr[i] - i]++
	}

	println(ans)
}

func main() {
	defer writer.Flush()
	var t int

	scanf("%d\n", &t)
	for t > 0 {
		test_case()
		t--
	}

}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)

	var t, n, a int
	fmt.Fscan(in, &t)

	for ; t > 0; t-- {
		fmt.Fscan(in, &n)
		m := make(map[int]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &a)
			m[a-i-1]++
		}
		cnt := 0
		for _, v := range m {
			cnt += (v - 1) * v / 2
		}

		fmt.Println(cnt)
	}
}


Vasiliy spent his vacation in a sanatorium, came back and found that he completely forgot details of his vacation! Every day there was a breakfast, a dinner and a supper in a dining room of the sanatorium (of course, in this order). The only thing that Vasiliy has now is a card from the dining room contaning notes how many times he had a breakfast, a dinner and a supper (thus, the card contains three integers). Vasiliy could sometimes have missed some meal, for example, he could have had a breakfast and a supper, but a dinner, or, probably, at some days he haven't been at the dining room at all.Vasiliy doesn't remember what was the time of the day when he arrived to sanatorium (before breakfast, before dinner, before supper or after supper), and the time when he left it (before breakfast, before dinner, before supper or after supper). So he considers any of these options. After Vasiliy arrived to the sanatorium, he was there all the time until he left. Please note, that it's possible that Vasiliy left the sanatorium on the same day he arrived.According to the notes in the card, help Vasiliy determine the minimum number of meals in the dining room that he could have missed. We shouldn't count as missed meals on the arrival day before Vasiliy's arrival and meals on the departure day after he left.

The only line contains three integers b, d and s (0 ≤ b, d, s ≤ 1018,  b + d + s ≥ 1) — the number of breakfasts, dinners and suppers which Vasiliy had during his vacation in the sanatorium.

Print single integer — the minimum possible number of meals which Vasiliy could have missed during his vacation.

NoteIn the first sample, Vasiliy could have missed one supper, for example, in case he have arrived before breakfast, have been in the sanatorium for two days (including the day of arrival) and then have left after breakfast on the third day. In the second sample, Vasiliy could have arrived before breakfast, have had it, and immediately have left the sanatorium, not missing any meal.In the third sample, Vasiliy could have been in the sanatorium for one day, not missing any meal.

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"sort"
)

func solve() {
    a := []int64{ readInt64(), readInt64(), readInt64() }
    b := []int64{ a[0], a[1], a[2] }
    sort.Sort(Ints64(b))
    init := int64(0)
    if b[2] > 10 {
        d := b[2] - 5
        for i := range a {
            if a[i] >= d {
                a[i] = a[i] - d
            } else {
                init += d - a[i]
                a[i] = 0
            }
        }
    }

    best := int64(10000)
    for stay := int64(-1); stay < 100; stay++ {
        for s := 0; s < 4; s++ {
            for e := 0; e < 4; e++ {
                ok, cur := true, int64(0)
                for i := range a {
                    av := int64(0)
                    if stay == -1 {
                        if s <= i && i < e {
                            av++
                        }
                    } else {
                        av = stay

                        if s <= i {
                            av++
                        }

                        if i < e {
                            av++
                        }
                    }

                    if av < a[i] {
                        ok = false
                    } else {
                        cur += av-a[i]
                    }
                }

                if ok && cur < best {
                    best = cur
                }
            }
        }
    }
    fmt.Println(best + init)
}

// Helpers

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

// Sort

type Ints64 []int64

func (a Ints64) Len() int           { return len(a) }
func (a Ints64) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Ints64) Less(i, j int) bool { return a[i] < a[j] }

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

import (
	"bufio"
	"fmt"
	"os"
)

var bufin *bufio.Reader
var bufout *bufio.Writer

func min(x int64, y int64) int64 {
	if x < y {
		return x
	}
	return y
}

func solution(b int64, d int64, s int64) int64 {
	m := min(min(b, d), s)
	b -= m
	d -= m
	s -= m

	if b+d+s == 0 {
		return 0
	}

	if b+d == 0 {
		return s - 1 + s - 1
	}

	if d+s == 0 {
		return b - 1 + b - 1
	}

	if s+b == 0 {
		return d - 1 + d - 1
	}

	if b == 0 {
		if d < s {
			return s - 1 + s - 1 - d
		} else if d > s {
			return d - 1 + d - 1 - s
		}
		// d == s
		return d - 1
	}

	if s == 0 {
		if b < d {
			return d - 1 + d - 1 - b
		} else if b > d {
			return b - 1 + b - 1 - d
		}
		// b == d
		return b - 1
	}

	// d == 0
	if b < s {
		return s - 1 + s - 1 - b
	} else if b > s {
		return b - 1 + b - 1 - s
	}
	// b == s
	return b - 1
}

func main() {
	bufin = bufio.NewReader(os.Stdin)
	bufout = bufio.NewWriter(os.Stdout)
	defer bufout.Flush()

	var b, d, s int64
	fmt.Fscanf(bufin, "%d %d %d\n", &b, &d, &s)
	fmt.Fprintf(bufout, "%d\n", solution(b, d, s))
}

package main

import "fmt"

func sortTriple(a, b, c *uint64) {
    if *a > *b {
        *a, *b = *b, *a
    }
    if *b > *c {
        *b, *c = *c, *b
    }
    if *a > *b {
        *a, *b = *b, *a
    }
}

func main() {
    var a, b, c, d uint64
    fmt.Scanf("%d %d %d\n", &a, &b, &c)
    sortTriple(&a, &b, &c)
    if c - b > 1 {
        d += c - b - 1
        b = c - 1
    }
    if c - b == 1 {
        if b - a > 0 {
            d += b - a
            a = b
        }
    } else {
        if b - a > 1 {
            d += b - a - 1
            a = b - 1
        }
    }
    fmt.Printf("%d\n", d)
}

package main

import "fmt"

func sort(a, b, c *int64) {
	if (*c > *b) {
		*b, *c = *c, *b
	}
	if (*b > *a) {
		*a, *b = *b, *a
	}
	if (*c > *b) {
		*b, *c = *c, *b
	}
}

func getAns(a, b, c int64) int64{
	if a == b && b == c {
		return 0
	}
	if a == b {
		return a - c - 1
	}
	return a * 3 - a - b - c - 2
}

func main() {
	var a, b, c int64
	fmt.Scan(&a, &b, &c)
	sort(&a, &b, &c)
	fmt.Println(getAns(a, b, c))
}

package main

import (
	"fmt"
)

func main() {
	d := make([]int64, 3)
	if _, err := fmt.Scanf("%d %d %d\n", &d[0], &d[1], &d[2]); err != nil {
		return
	}

	mi, mc := max_index(d)
	if mc == 3 {
		fmt.Println(0)
	} else if mc == 2 {
		fmt.Println(d[mi]*3 - 1 - d[0] - d[1] - d[2])
	} else {
		fmt.Println(d[mi]*3 - 2 - d[0] - d[1] - d[2])
	}
}

func max_index(d []int64) (int, int) {
	max := d[0]
	max_i := 0
	max_count := 1
	for i := 1; i < len(d); i++ {
		if d[i] > max {
			max_i = i
			max = d[i]
			max_count = 1
		} else if d[i] == max {
			max_count++
		}
	}
	return max_i, max_count
}

package main

import "fmt"

func Max(x int64, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

func main() {
	var b, d, s int64
	fmt.Scanf("%d %d %d\n", &b, &d, &s)

	var max int64 = Max(b, Max(d, s))

	var result int64 = 0
	if b < max-1 {
		result += max - b - 1
	}
	if d < max-1 {
		result += max - d - 1
	}
	if s < max-1 {
		result += max - s - 1
	}

	fmt.Printf("%d\n", result)
}

package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r:rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf) + 1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf) + 1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

func max(a int64, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func main() {
	sc := NewScanner()
	A := sc.NextInt64Array()
	ans := int64(1)

	for i := 0; i < 4; i++ {
		L := make([]int64, 3)
		for j := i; j < 3; j++ {
			L[j]++
		}
		for k := -1; k < 3; k++ {
			if k >= 0 {
				L[k]++
			}
			ok := true
			sm := int64(0)

			mx := A[0] - L[0]
			for q := 1; q < 3; q++ {
				mx = max(mx, A[q] - L[q])
			}
			for q := 0; q < 3; q++ {
				sm += A[q] - L[q] - mx
			}

			if ok {
				if ans == int64(1) || ans < sm {
					ans = sm
				}
			}
		}
	}
	fmt.Println(-ans)

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"sort"
)

func solve() {
    a := []int64{ readInt64(), readInt64(), readInt64() }
    b := []int64{ a[0], a[1], a[2] }
    sort.Sort(Ints64(b))
    init := int64(0)
    if b[2] > 10 {
        d := b[2] - 5
        for i := range a {
            if a[i] >= d {
                a[i] = a[i] - d
            } else {
                init += d - a[i]
                a[i] = 0
            }
        }
    }

    best := int64(10000)
    for stay := int64(0); stay < 100; stay++ {
        for s := 0; s < 4; s++ {
            for e := 0; e < 4; e++ {
                ok, cur := true, int64(0)
                for i := range a {
                    av := stay
                    if i >= s {
                        av++
                    }
                    if i < e {
                        av++
                    }
                    if av < a[i] {
                        ok = false
                    } else {
                        cur += av-a[i]
                    }
                }
                if ok && cur < best {
                    best = cur
                }
            }
        }
    }
    fmt.Println(best + init)
}

// Helpers

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

// Sort

type Ints64 []int64

func (a Ints64) Len() int           { return len(a) }
func (a Ints64) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Ints64) Less(i, j int) bool { return a[i] < a[j] }

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"sort"
)

func solve() {
    a := []int64{ readInt64(), readInt64(), readInt64() }
    b := []int64{ a[0], a[1], a[2] }
    sort.Sort(Ints64(b))
    init := int64(0)
    if b[2] > 10 {
        d := b[2] - 5
        for i := range a {
            if a[i] >= d {
                a[i] = a[i] - d
            } else {
                init += d - a[i]
                a[i] = 0
            }
        }
    }

    best := int64(10000)
    for stay := int64(0); stay < 100; stay++ {
        for s := 0; s < 4; s++ {
            for e := 0; e < 4; e++ {
                ok, cur := true, int64(0)
                for i := range a {
                    av := stay
                    if stay > 0 {
                        if i >= s {
                            av++
                        }
                        if i < e {
                            av++
                        }
                    } else {
                        if i >= s && i < e {
                            av++
                        }
                    }
                    if av < a[i] {
                        ok = false
                    } else {
                        cur += av-a[i]
                    }
                }

                if ok && cur < best {
                    best = cur
                }
            }
        }
    }
    fmt.Println(best + init)
}

// Helpers

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

// Sort

type Ints64 []int64

func (a Ints64) Len() int           { return len(a) }
func (a Ints64) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Ints64) Less(i, j int) bool { return a[i] < a[j] }

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

import "fmt"

func sort(a, b, c *int64) {
	if (*c > *b) {
		*b, *c = *c, *b
	}
	if (*b > *a) {
		*a, *b = *b, *c
	}
	if (*c > *b) {
		*b, *c = *c, *b
	}
}

func getAns(a, b, c int64) int64{
	if a == b && b == c {
		return 0
	}
	if a == b {
		return a - c - 1
	}
	return a * 3 - a - b - c - 2
}

func main() {
	var a, b, c int64
	fmt.Scan(&a, &b, &c)
	sort(&a, &b, &c)
	fmt.Println(getAns(a, b, c))
}

package main

import "fmt"

func Max(x int64, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

func main() {
	var b, d, s int64
	fmt.Scanf("%d %d %d\n", &b, &d, &s)

	var max int64 = Max(b, Max(d, s))

	var result int64 = 0
	if b < max-1 {
		result += max - b + 1
	}
	if d < max-1 {
		result += max - d - 1
	}
	if s < max-1 {
		result += max - s - 1
	}

	fmt.Printf("%d\n", result)
}

package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r:rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf) + 1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf) + 1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

func max(a int64, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func main() {
	sc := NewScanner()
	A := sc.NextInt64Array()
	ans := int64(1)

	for i := 0; i < 4; i++ {
		L := make([]int64, 3)
		for j := i; j < 3; j++ {
			L[j]++
		}
		for k := -1; k < 3; k++ {
			if k >= 0 {
				L[k]++
			}
			ok := true
			sm := int64(0)

			mx := A[0] - L[0]

			for q := 1; q < 3; q++ {
				mx = max(mx, A[q] - L[q])
			}
			for q := 0; q < 3; q++ {
				sm += A[q] - L[q] - mx
				if A[q] - L[q] - mx > 0 {
					ok = false
				}
			}

			if ok {
				if ans == int64(1) || ans < sm {
					ans = sm
				}
			}
		}
	}
	fmt.Println(-ans)

}


Let's call a set of positive integers $$$a_1, a_2, \dots, a_k$$$ quadratic if the product of the factorials of its elements is a square of an integer, i. e. $$$\prod\limits_{i=1}^{k} a_i! = m^2$$$, for some integer $$$m$$$.You are given a positive integer $$$n$$$.Your task is to find a quadratic subset of a set $$$1, 2, \dots, n$$$ of maximum size. If there are multiple answers, print any of them.

A single line contains a single integer $$$n$$$ ($$$1 \le n \le 10^6$$$).

In the first line, print a single integer — the size of the maximum subset. In the second line, print the subset itself in an arbitrary order.

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"math/rand"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	n := readNum(reader)

	res := solve(n)

	var buf bytes.Buffer

	buf.WriteString(fmt.Sprintf("%d\n", len(res)))

	for i := 0; i < len(res); i++ {
		buf.WriteString(fmt.Sprintf("%d ", res[i]))
	}
	buf.WriteByte('\n')
	fmt.Print(buf.String())
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

var pr []int
var f []int64
var rf map[int64]int

func prepare(MAX_N int) {
	pr = make([]int, MAX_N)

	rd := rand.NewSource(17)
	hs := make([]int64, MAX_N)

	for i := 2; i < MAX_N; i++ {
		if pr[i] == 0 {
			for j := i; j < MAX_N; j += i {
				if pr[j] == 0 {
					pr[j] = i
				}
			}
		}
		hs[i] = rd.Int63()
	}

	f = make([]int64, MAX_N)

	rf = make(map[int64]int)

	for i := 2; i < MAX_N; i++ {
		f[i] = f[i-1]
		x := i
		for x > 1 {
			f[i] ^= hs[pr[x]]
			x /= pr[x]
		}
		rf[f[i]] = i
	}
}

func solve(n int) []int {
	prepare(n + 1)
	check := func() []int {
		var fp int64

		for i := 2; i <= n; i++ {
			fp ^= f[i]
		}

		if fp == 0 {
			return nil
		}
		if v, ok := rf[fp]; ok {
			return []int{v}
		}
		for i := 2; i <= n; i++ {
			x := f[i] ^ fp
			if v, ok := rf[x]; ok && v != i {
				return []int{v, i}
			}
		}
		return []int{2, n / 2, n}
	}
	rem := check()
	ans := make([]int, 0, n-len(rem))

	for i := 1; i <= n; i++ {
		if !find(rem, i) {
			ans = append(ans, i)
		}
	}
	return ans
}

func find(arr []int, target int) bool {
	for _, num := range arr {
		if num == target {
			return true
		}
	}
	return false
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"math/rand"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	n := readNum(reader)

	res := solve(n)

	var buf bytes.Buffer

	buf.WriteString(fmt.Sprintf("%d\n", len(res)))

	for i := 0; i < len(res); i++ {
		buf.WriteString(fmt.Sprintf("%d ", res[i]))
	}
	buf.WriteByte('\n')
	fmt.Print(buf.String())
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

const MAX_N = 1000010

var pr []int
var f []int64
var rf map[int64]int

func init() {
	pr = make([]int, MAX_N)

	rd := rand.NewSource(17)
	hs := make([]int64, MAX_N)

	for i := 2; i < MAX_N; i++ {
		if pr[i] == 0 {
			for j := i; j < MAX_N; j += i {
				if pr[j] == 0 {
					pr[j] = i
				}
			}
		}
		hs[i] = rd.Int63()
	}

	f = make([]int64, MAX_N)

	rf = make(map[int64]int)

	for i := 2; i < MAX_N; i++ {
		f[i] = f[i-1]
		x := i
		for x > 1 {
			f[i] ^= hs[pr[x]]
			x /= pr[x]
		}
		rf[f[i]] = i
	}
}

func solve(n int) []int {

	check := func() []int {
		var fp int64

		for i := 2; i <= n; i++ {
			fp ^= f[i]
		}

		if fp == 0 {
			return nil
		}
		if v, ok := rf[fp]; ok {
			return []int{v}
		}
		for i := 2; i <= n; i++ {
			x := f[i] ^ fp
			if v, ok := rf[x]; ok && v != i {
				return []int{v, i}
			}
		}
		return []int{2, n / 2, n}
	}
	rem := check()
	ans := make([]int, 0, n-len(rem))

	for i := 1; i <= n; i++ {
		if !find(rem, i) {
			ans = append(ans, i)
		}
	}
	return ans
}

func find(arr []int, target int) bool {
	for _, num := range arr {
		if num == target {
			return true
		}
	}
	return false
}