n=int(eval(input()))

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

c,d=dict(),dict()

for i in range(n):

    if i+1-a[i] in c:

        c[i+1-a[i]]+=1

    else:

        c[i+1-a[i]]=1

    if i+1+a[i] in d:

        d[i+1+a[i]]+=1

    else:

        d[i+1+a[i]]=1

ans=0

for i in c:

    if i in d:

        ans+=(c[i]*d[i])

print(ans)

import collections



N = int(eval(input()))

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



L = [i + A[i] for i in range(N)]

R = [i - A[i] for i in range(N)]



countL = collections.Counter(L)

countR = collections.Counter(R)



print((sum([countL[n] * countR[n] for n in list(countL.keys())])))
n = int(eval(input()))
a = list(map(int, input().split()))
c, d = dict(), dict()
for i in range(n):
    if i + 1 - a[i] in c:
        c[i + 1 - a[i]] += 1
    else:
        c[i + 1 - a[i]] = 1
    if i + 1 + a[i] in d:
        d[i + 1 + a[i]] += 1
    else:
        d[i + 1 + a[i]] = 1
ans = 0
for i in c:
    if i in d:
        ans += c[i] * d[i]
print(ans)

import collections

N = int(eval(input()))
A = list(map(int, input().split()))
L = [i + A[i] for i in range(N)]
R = [i - A[i] for i in range(N)]
countL = collections.Counter(L)
countR = collections.Counter(R)
print((sum([countL[n] * countR[n] for n in list(countL.keys())])))

-n = int(eval(input())) -a = list(map(int, input().split())) -c, d = dict(), dict() -for i in range(n): -    if i + 1 - a[i] in c: -        c[i + 1 - a[i]] += 1 -    else: -        c[i + 1 - a[i]] = 1 -    if i + 1 + a[i] in d: -        d[i + 1 + a[i]] += 1 -    else: -        d[i + 1 + a[i]] = 1 -ans = 0 -for i in c: -    if i in d: -        ans += c[i] * d[i] -print(ans) +import collections + +N = int(eval(input())) +A = list(map(int, input().split())) +L = [i + A[i] for i in range(N)] +R = [i - A[i] for i in range(N)] +countL = collections.Counter(L) +countR = collections.Counter(R) +print((sum([countL[n] * countR[n] for n in list(countL.keys())])))