N = int(eval(input()))

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

A1 = [[-a-i,i] for i, a in enumerate(A)]

A2 = [[a-i,i] for i, a in enumerate(A)]

A1.sort()

A2.sort()

i = j = 0

cnt = 0

while i < N and j < N:

    if A1[i][0] == A2[j][0]:

        buf1 = 1

        for k in range(i+1, N):

            if A1[k][0] != A1[i][0]:

                break

            buf1 += 1

        buf2 = 1

        for k in range(j+1, N):

            if A2[k][0] != A2[j][0]:

                break

            buf2 += 1

        cnt += buf1 * buf2

        i += buf1

        j += buf2

    elif A1[i][0] < A2[j][0]:

        i += 1

    else:

        j += 1

print(cnt)

N = int(eval(input()))

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



A1, A2 = {}, {}

for i, a in enumerate(A):

    key1 = str(-a-i)

    if key1 in A1:

        A1[key1] = (key1 in A1) * A1[key1] + 1

    else:

        A1[key1] = 1

    key2 = str(a-i)

    if key2 in A2:

        A2[key2] += 1

    else:

        A2[key2] = 1



cnt = 0

for key, value in list(A1.items()):

    if key in A2:

        cnt += value * A2[key]



print(cnt)

N = int(eval(input()))
A = list(map(int, input().split()))
A1 = [[-a - i, i] for i, a in enumerate(A)]
A2 = [[a - i, i] for i, a in enumerate(A)]
A1.sort()
A2.sort()
i = j = 0
cnt = 0
while i < N and j < N:
    if A1[i][0] == A2[j][0]:
        buf1 = 1
        for k in range(i + 1, N):
            if A1[k][0] != A1[i][0]:
                break
            buf1 += 1
        buf2 = 1
        for k in range(j + 1, N):
            if A2[k][0] != A2[j][0]:
                break
            buf2 += 1
        cnt += buf1 * buf2
        i += buf1
        j += buf2
    elif A1[i][0] < A2[j][0]:
        i += 1
    else:
        j += 1
print(cnt)

N = int(eval(input()))
A = list(map(int, input().split()))
A1, A2 = {}, {}
for i, a in enumerate(A):
    key1 = str(-a - i)
    if key1 in A1:
        A1[key1] = (key1 in A1) * A1[key1] + 1
    else:
        A1[key1] = 1
    key2 = str(a - i)
    if key2 in A2:
        A2[key2] += 1
    else:
        A2[key2] = 1
cnt = 0
for key, value in list(A1.items()):
    if key in A2:
        cnt += value * A2[key]
print(cnt)

-A1 = [[-a - i, i] for i, a in enumerate(A)] -A2 = [[a - i, i] for i, a in enumerate(A)] -A1.sort() -A2.sort() -i = j = 0 +A1, A2 = {}, {} +for i, a in enumerate(A): +    key1 = str(-a - i) +    if key1 in A1: +        A1[key1] = (key1 in A1) * A1[key1] + 1 +    else: +        A1[key1] = 1 +    key2 = str(a - i) +    if key2 in A2: +        A2[key2] += 1 +    else: +        A2[key2] = 1 -while i < N and j < N: -    if A1[i][0] == A2[j][0]: -        buf1 = 1 -        for k in range(i + 1, N): -            if A1[k][0] != A1[i][0]: -                break -            buf1 += 1 -        buf2 = 1 -        for k in range(j + 1, N): -            if A2[k][0] != A2[j][0]: -                break -            buf2 += 1 -        cnt += buf1 * buf2 -        i += buf1 -        j += buf2 -    elif A1[i][0] < A2[j][0]: -        i += 1 -    else: -        j += 1 +for key, value in list(A1.items()): +    if key in A2: +        cnt += value * A2[key]