from collections import defaultdict



N = int(eval(input()))

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



di = defaultdict(int)

dj = defaultdict(int)

for i in range(1, N+1):

  di[i + A[i-1]] += 1

  dj[i - A[i-1]] += 1



ans = 0

for key in list(di.keys()):

  ans += dj[key] * di[key]



print(ans)
from collections import defaultdict



N = int(eval(input()))

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



ans = 0

di = defaultdict(int)

for i, a in enumerate(A):

    ans += di[i+1 - a]

    di[i+1 + a] += 1



print(ans)
from collections import defaultdict

N = int(eval(input()))
A = list(map(int, input().split()))
di = defaultdict(int)
dj = defaultdict(int)
for i in range(1, N + 1):
    di[i + A[i - 1]] += 1
    dj[i - A[i - 1]] += 1
ans = 0
for key in list(di.keys()):
    ans += dj[key] * di[key]
print(ans)

from collections import defaultdict

N = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
di = defaultdict(int)
for i, a in enumerate(A):
    ans += di[i + 1 - a]
    di[i + 1 + a] += 1
print(ans)

+ans = 0 -dj = defaultdict(int) -for i in range(1, N + 1): -    di[i + A[i - 1]] += 1 -    dj[i - A[i - 1]] += 1 -ans = 0 -for key in list(di.keys()): -    ans += dj[key] * di[key] +for i, a in enumerate(A): +    ans += di[i + 1 - a] +    di[i + 1 + a] += 1