from collections import defaultdict

import bisect

N = int(eval(input()))

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

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

diff = [-A[i]+(i+1) for i in range(N)]



plusc = defaultdict(list)

for i in range(N):

    plusc[plus[i]].append(i)

ans = 0

for i in range(1,N):

    ans += bisect.bisect_left(plusc[diff[i]],i)

print(ans)
N = int(eval(input()))

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

count = 0

dicta = {}

for i in range(N):

    if i - A[i] in dicta:

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

    if i + A[i] in dicta:

        dicta[i+A[i]] += 1

    else:

        dicta[i+A[i]] = 1

print(count)
from collections import defaultdict
import bisect

N = int(eval(input()))
A = list(map(int, input().split()))
plus = [A[i] + (i + 1) for i in range(N)]
diff = [-A[i] + (i + 1) for i in range(N)]
plusc = defaultdict(list)
for i in range(N):
    plusc[plus[i]].append(i)
ans = 0
for i in range(1, N):
    ans += bisect.bisect_left(plusc[diff[i]], i)
print(ans)

N = int(eval(input()))
A = list(map(int, input().split()))
count = 0
dicta = {}
for i in range(N):
    if i - A[i] in dicta:
        count += dicta[i - A[i]]
    if i + A[i] in dicta:
        dicta[i + A[i]] += 1
    else:
        dicta[i + A[i]] = 1
print(count)

-from collections import defaultdict -import bisect - -plus = [A[i] + (i + 1) for i in range(N)] -diff = [-A[i] + (i + 1) for i in range(N)] -plusc = defaultdict(list) +count = 0 +dicta = {} -    plusc[plus[i]].append(i) -ans = 0 -for i in range(1, N): -    ans += bisect.bisect_left(plusc[diff[i]], i) -print(ans) +    if i - A[i] in dicta: +        count += dicta[i - A[i]] +    if i + A[i] in dicta: +        dicta[i + A[i]] += 1 +    else: +        dicta[i + A[i]] = 1 +print(count)