import collections



N = int(eval(input()))

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

B = collections.defaultdict(int)

C = collections.defaultdict(int)



for i in range(N):

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

    C[i+A[i]] += 1

#print(B)

#print(C)

ans = 0

for i in B:

    #print(i) i=Key

    ans += B[i]*C[i]

print(ans)
import collections



N = int(eval(input()))

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

B = {}

C = {}



for i in range(N):

    if i-A[i] in B:

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

    else:

        B[i-A[i]] = 1

    if i+A[i] in C:

        C[i+A[i]] += 1

    else:

        C[i+A[i]] = 1

#print(B)

#print(C)

ans = 0

for i in B:

    #print(i) i=Key

    if i in C:

        ans += B[i]*C[i]

print(ans)
import collections

N = int(eval(input()))
A = list(map(int, input().split()))
B = collections.defaultdict(int)
C = collections.defaultdict(int)
for i in range(N):
    B[i - A[i]] += 1
    C[i + A[i]] += 1
# print(B)
# print(C)
ans = 0
for i in B:
    # print(i) i=Key
    ans += B[i] * C[i]
print(ans)

import collections

N = int(eval(input()))
A = list(map(int, input().split()))
B = {}
C = {}
for i in range(N):
    if i - A[i] in B:
        B[i - A[i]] += 1
    else:
        B[i - A[i]] = 1
    if i + A[i] in C:
        C[i + A[i]] += 1
    else:
        C[i + A[i]] = 1
# print(B)
# print(C)
ans = 0
for i in B:
    # print(i) i=Key
    if i in C:
        ans += B[i] * C[i]
print(ans)

-B = collections.defaultdict(int) -C = collections.defaultdict(int) +B = {} +C = {} -    B[i - A[i]] += 1 -    C[i + A[i]] += 1 +    if i - A[i] in B: +        B[i - A[i]] += 1 +    else: +        B[i - A[i]] = 1 +    if i + A[i] in C: +        C[i + A[i]] += 1 +    else: +        C[i + A[i]] = 1 -    ans += B[i] * C[i] +    if i in C: +        ans += B[i] * C[i]