N = int(eval(input()))

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



X = dict()

ans = 0

for i in range(N):

    L = i + A[i]

    if L not in X:

        X[L] = 1

    else:

        X[L] += 1



for i in range(N):

    R = i - A[i]

    if R in X:

        ans += X[R]

        

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

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



X = dict()

ans = 0

for i in range(N):

    L = i + A[i]

    R = i - A[i]

    if L not in X:

        X[L] = 1

    else:

        X[L] += 1

    if R in X:

        ans += X[R]

        

print(ans)
N = int(eval(input()))
A = list(map(int, input().split()))
X = dict()
ans = 0
for i in range(N):
    L = i + A[i]
    if L not in X:
        X[L] = 1
    else:
        X[L] += 1
for i in range(N):
    R = i - A[i]
    if R in X:
        ans += X[R]
print(ans)

N = int(eval(input()))
A = list(map(int, input().split()))
X = dict()
ans = 0
for i in range(N):
    L = i + A[i]
    R = i - A[i]
    if L not in X:
        X[L] = 1
    else:
        X[L] += 1
    if R in X:
        ans += X[R]
print(ans)

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