N = int(eval(input()))

A = [int(i) for i in input().split()]

dp = [0] * 10 ** 7

ans = 0

for i in range(N):

    x = i + 1 - A[i]

    if x >= 0:

        ans += dp[x]

    y = i + 1 + A[i]

    if y < 10 ** 7:

        dp[y] += 1



print(ans)

N = int(eval(input()))

A = [int(i) for i in input().split()]

INF = 2 * 10 ** 5

dp = [0] * INF

ans = 0

for i in range(N):

    i_i_ = i + 1 - A[i]

    if 0 < i_i_ < INF:

        ans += dp[i_i_]

    i_ = i + 1 + A[i]

    if 0 < i_ < INF:

        dp[i_] += 1



print(ans)
N = int(eval(input()))
A = [int(i) for i in input().split()]
dp = [0] * 10**7
ans = 0
for i in range(N):
    x = i + 1 - A[i]
    if x >= 0:
        ans += dp[x]
    y = i + 1 + A[i]
    if y < 10**7:
        dp[y] += 1
print(ans)

N = int(eval(input()))
A = [int(i) for i in input().split()]
INF = 2 * 10**5
dp = [0] * INF
ans = 0
for i in range(N):
    i_i_ = i + 1 - A[i]
    if 0 < i_i_ < INF:
        ans += dp[i_i_]
    i_ = i + 1 + A[i]
    if 0 < i_ < INF:
        dp[i_] += 1
print(ans)

-dp = [0] * 10**7 +INF = 2 * 10**5 +dp = [0] * INF -    x = i + 1 - A[i] -    if x >= 0: -        ans += dp[x] -    y = i + 1 + A[i] -    if y < 10**7: -        dp[y] += 1 +    i_i_ = i + 1 - A[i] +    if 0 < i_i_ < INF: +        ans += dp[i_i_] +    i_ = i + 1 + A[i] +    if 0 < i_ < INF: +        dp[i_] += 1