#E

N = int(eval(input()))

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

p = {}



ans = 0

for i in range(N):

    if i+1-A[i] in p:

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

    if A[i] + (i+1) in p:

        p[i+1+A[i]] += 1

    else:

        p[i+1+A[i]] = 1

    

#print(p)

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

A = [0]+list(map(int,input().split()))



d = {}



ans = 0

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

    if i+A[i] not in d:

        d[i+A[i]] = 1

    else:

        d[i+A[i]] += 1

    if i-A[i] in d:

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

        

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

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

-# E -N = int(eval(input())) -A = list(map(int, input().split())) -p = {} +n = int(eval(input())) +A = [0] + list(map(int, input().split())) +d = {} -for i in range(N): -    if i + 1 - A[i] in p: -        ans += p[i + 1 - A[i]] -    if A[i] + (i + 1) in p: -        p[i + 1 + A[i]] += 1 +for i in range(1, n + 1): +    if i + A[i] not in d: +        d[i + A[i]] = 1 -        p[i + 1 + A[i]] = 1 -# print(p) +        d[i + A[i]] += 1 +    if i - A[i] in d: +        ans += d[i - A[i]]