from collections import Counter



n=int(eval(input()))

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



q1=[]

q2=[]



for i in range(n):

  q1.append(i+a[i])

  q2.append(i-a[i])



c1=Counter(q1)

c2=Counter(q2)



ans=0

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

  num1=c1[i]

  num2=c2[i]

  ans+=num1*num2



print(ans)
from collections import Counter



n=int(eval(input()))

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



q1=[]

q2=[]



for i in range(n):

  q1.append(i+a[i])

  q2.append(i-a[i])



c2=Counter(q2)



ans=0

for i in q1:

  ans+=c2[i]



print(ans)
from collections import Counter

n = int(eval(input()))
a = list(map(int, input().split()))
q1 = []
q2 = []
for i in range(n):
    q1.append(i + a[i])
    q2.append(i - a[i])
c1 = Counter(q1)
c2 = Counter(q2)
ans = 0
for i in list(c1.keys()):
    num1 = c1[i]
    num2 = c2[i]
    ans += num1 * num2
print(ans)

from collections import Counter

n = int(eval(input()))
a = list(map(int, input().split()))
q1 = []
q2 = []
for i in range(n):
    q1.append(i + a[i])
    q2.append(i - a[i])
c2 = Counter(q2)
ans = 0
for i in q1:
    ans += c2[i]
print(ans)

-c1 = Counter(q1) -for i in list(c1.keys()): -    num1 = c1[i] -    num2 = c2[i] -    ans += num1 * num2 +for i in q1: +    ans += c2[i]