# N人の参加者, 参加者iの身長はAi, 背番号の差の絶対値が身長の和に等しい組

from collections import defaultdict

N = int(eval(input()))

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

memo = defaultdict(int)

ans = 0

for i, x in enumerate(A, 1):

    ans += memo[i-A[i-1]]

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

print(ans)

from collections import defaultdict

N = int(eval(input()))

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

count = defaultdict(int)

ans = 0

for i in range(N):

    ans += count[i-A[i]]

    count[A[i]+i] += 1

print(ans)

# N人の参加者, 参加者iの身長はAi, 背番号の差の絶対値が身長の和に等しい組
from collections import defaultdict

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

from collections import defaultdict

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

-# N人の参加者, 参加者iの身長はAi, 背番号の差の絶対値が身長の和に等しい組 -memo = defaultdict(int) +count = defaultdict(int) -for i, x in enumerate(A, 1): -    ans += memo[i - A[i - 1]] -    memo[i + A[i - 1]] += 1 +for i in range(N): +    ans += count[i - A[i]] +    count[A[i] + i] += 1