n = int(eval(input()))

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



fromLeft = [-1]*n



for i in range(n):

    fromLeft[i] = a[i] - i



ans = 0



ldList = [0]*(n*2+5)



for i in reversed(list(range(n))):

    if 0 <= fromLeft[i]+n+1 and fromLeft[i]+n+1 < n*2+5:

        ldList[fromLeft[i]+n+1] += 1

    if 0 <= -1*a[i]-i+n+1 and -1*a[i]-i+n+1 < n*2+5:

        ans += ldList[-1*a[i]-i+n+1]



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

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



fromLeftA = [-1]*n



for i in range(n):

    fromLeftA[i] = a[i] - i



ans = 0

ldList = [0]*(n*2)



for i in reversed(list(range(n))):

    if 0 <= fromLeftA[i]+n and fromLeftA[i]+n < n*2:

        ldList[fromLeftA[i]+n] += 1

    if 0 <= -1*a[i]-i+n and -1*a[i]-i+n < n*2:

        ans += ldList[-1*a[i]-i+n]



print(ans)
n = int(eval(input()))
a = list(map(int, input().split()))
fromLeft = [-1] * n
for i in range(n):
    fromLeft[i] = a[i] - i
ans = 0
ldList = [0] * (n * 2 + 5)
for i in reversed(list(range(n))):
    if 0 <= fromLeft[i] + n + 1 and fromLeft[i] + n + 1 < n * 2 + 5:
        ldList[fromLeft[i] + n + 1] += 1
    if 0 <= -1 * a[i] - i + n + 1 and -1 * a[i] - i + n + 1 < n * 2 + 5:
        ans += ldList[-1 * a[i] - i + n + 1]
print(ans)

n = int(eval(input()))
a = list(map(int, input().split()))
fromLeftA = [-1] * n
for i in range(n):
    fromLeftA[i] = a[i] - i
ans = 0
ldList = [0] * (n * 2)
for i in reversed(list(range(n))):
    if 0 <= fromLeftA[i] + n and fromLeftA[i] + n < n * 2:
        ldList[fromLeftA[i] + n] += 1
    if 0 <= -1 * a[i] - i + n and -1 * a[i] - i + n < n * 2:
        ans += ldList[-1 * a[i] - i + n]
print(ans)

-fromLeft = [-1] * n +fromLeftA = [-1] * n -    fromLeft[i] = a[i] - i +    fromLeftA[i] = a[i] - i -ldList = [0] * (n * 2 + 5) +ldList = [0] * (n * 2) -    if 0 <= fromLeft[i] + n + 1 and fromLeft[i] + n + 1 < n * 2 + 5: -        ldList[fromLeft[i] + n + 1] += 1 -    if 0 <= -1 * a[i] - i + n + 1 and -1 * a[i] - i + n + 1 < n * 2 + 5: -        ans += ldList[-1 * a[i] - i + n + 1] +    if 0 <= fromLeftA[i] + n and fromLeftA[i] + n < n * 2: +        ldList[fromLeftA[i] + n] += 1 +    if 0 <= -1 * a[i] - i + n and -1 * a[i] - i + n < n * 2: +        ans += ldList[-1 * a[i] - i + n]