from collections import Counter



n=int(eval(input()))

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



i_l=[]

j_l=[]

for i in range(n):

  i_l.append(i+a[i])

  j_l.append(i-a[i])



ci=Counter(i_l)

cl=Counter(j_l)



ans=0

for k,v in list(ci.items()):

  ans+=v*cl[k]



print(ans)
from sys import stdin

nii=lambda:list(map(int,stdin.readline().split()))

lnii=lambda:list(map(int,stdin.readline().split()))

from collections import Counter



n=int(eval(input()))

a=lnii()



l1=[i+a[i] for i in range(n)]

l2=[i-a[i] for i in range(n)]



c1=Counter(l1)

c2=Counter(l2)



ans=0

for i in c1:

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



print(ans)
from collections import Counter

n = int(eval(input()))
a = list(map(int, input().split()))
i_l = []
j_l = []
for i in range(n):
    i_l.append(i + a[i])
    j_l.append(i - a[i])
ci = Counter(i_l)
cl = Counter(j_l)
ans = 0
for k, v in list(ci.items()):
    ans += v * cl[k]
print(ans)

from sys import stdin

nii = lambda: list(map(int, stdin.readline().split()))
lnii = lambda: list(map(int, stdin.readline().split()))
from collections import Counter

n = int(eval(input()))
a = lnii()
l1 = [i + a[i] for i in range(n)]
l2 = [i - a[i] for i in range(n)]
c1 = Counter(l1)
c2 = Counter(l2)
ans = 0
for i in c1:
    ans += c1[i] * c2[i]
print(ans)

+from sys import stdin + +nii = lambda: list(map(int, stdin.readline().split())) +lnii = lambda: list(map(int, stdin.readline().split())) -a = list(map(int, input().split())) -i_l = [] -j_l = [] -for i in range(n): -    i_l.append(i + a[i]) -    j_l.append(i - a[i]) -ci = Counter(i_l) -cl = Counter(j_l) +a = lnii() +l1 = [i + a[i] for i in range(n)] +l2 = [i - a[i] for i in range(n)] +c1 = Counter(l1) +c2 = Counter(l2) -for k, v in list(ci.items()): -    ans += v * cl[k] +for i in c1: +    ans += c1[i] * c2[i]