n=int(eval(input()))

a=list(map(int,input().split()))

from collections import Counter

ai,aj=[],[]

for i in range(n):

  aj.append(i-a[i])

  ai.append(i+a[i])

c1=Counter(ai)

c2=Counter(aj)

ans=0

for k in list(c1.keys()):

  ans+=c1[k]*c2[k]

print(ans)





n = int(eval(input()))

a = list(map(int,input().split()))



x = [ aa + i  for i,aa in enumerate(a,start = 1)]

y = [ i - aa  for i,aa in enumerate(a,start = 1)]



from collections import Counter

c = Counter(y)

ans = 0

for xx in x:

    ans += c[xx]

print(ans)







n = int(eval(input()))
a = list(map(int, input().split()))
from collections import Counter

ai, aj = [], []
for i in range(n):
    aj.append(i - a[i])
    ai.append(i + a[i])
c1 = Counter(ai)
c2 = Counter(aj)
ans = 0
for k in list(c1.keys()):
    ans += c1[k] * c2[k]
print(ans)

n = int(eval(input()))
a = list(map(int, input().split()))
x = [aa + i for i, aa in enumerate(a, start=1)]
y = [i - aa for i, aa in enumerate(a, start=1)]
from collections import Counter

c = Counter(y)
ans = 0
for xx in x:
    ans += c[xx]
print(ans)

+x = [aa + i for i, aa in enumerate(a, start=1)] +y = [i - aa for i, aa in enumerate(a, start=1)] -ai, aj = [], [] -for i in range(n): -    aj.append(i - a[i]) -    ai.append(i + a[i]) -c1 = Counter(ai) -c2 = Counter(aj) +c = Counter(y) -for k in list(c1.keys()): -    ans += c1[k] * c2[k] +for xx in x: +    ans += c[xx]