from collections import*

n,*a=list(map(int,open(0).read().split()))

s=0

d=defaultdict(int)

for i,a in enumerate(a):

  s+=d[i-a]

  d[i+a]+=1

print(s)
n,*a=list(map(int,open(0).read().split()))

i=s=0

d=[0]*n

for a in a:

  if i>=a:s+=d[i-a]

  if i+a<n:d[i+a]+=1

  i+=1

print(s)
from collections import *

n, *a = list(map(int, open(0).read().split()))
s = 0
d = defaultdict(int)
for i, a in enumerate(a):
    s += d[i - a]
    d[i + a] += 1
print(s)

n, *a = list(map(int, open(0).read().split()))
i = s = 0
d = [0] * n
for a in a:
    if i >= a:
        s += d[i - a]
    if i + a < n:
        d[i + a] += 1
    i += 1
print(s)

-from collections import * - -s = 0 -d = defaultdict(int) -for i, a in enumerate(a): -    s += d[i - a] -    d[i + a] += 1 +i = s = 0 +d = [0] * n +for a in a: +    if i >= a: +        s += d[i - a] +    if i + a < n: +        d[i + a] += 1 +    i += 1