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

from collections import*

d=defaultdict(int)

a=0

for i in range(n): d[i+l[i]]+=1; a+=d[i-l[i]]*(i>l[i])

print(a)
n,*l=list(map(int,open(0).read().split()));d,a={},0

for i in range(n):d[i+l[i]]=d.get(i+l[i],0)+1;a+=d.get(i-l[i],0)

print(a)
n, *l = list(map(int, open(0).read().split()))
from collections import *

d = defaultdict(int)
a = 0
for i in range(n):
    d[i + l[i]] += 1
    a += d[i - l[i]] * (i > l[i])
print(a)

n, *l = list(map(int, open(0).read().split()))
d, a = {}, 0
for i in range(n):
    d[i + l[i]] = d.get(i + l[i], 0) + 1
    a += d.get(i - l[i], 0)
print(a)

-from collections import * - -d = defaultdict(int) -a = 0 +d, a = {}, 0 -    d[i + l[i]] += 1 -    a += d[i - l[i]] * (i > l[i]) +    d[i + l[i]] = d.get(i + l[i], 0) + 1 +    a += d.get(i - l[i], 0)