n = int(eval(input()))

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



add1 = []

sub1 = []

for i in range(n):

    add1.append(a[i] + i)

    sub1.append(i - a[i])



dict1 = {}

dict2 = {}

for i in add1:

    if i in dict1:

        dict1[i] += 1

    else:

        dict1[i] = 1

for i in sub1:

    if i in dict2:

        dict2[i] += 1

    else:

        dict2[i] = 1



sorted1 = sorted(list(dict1.items()), key = lambda x: x[0])

sorted2 = sorted(list(dict2.items()), key = lambda x: x[0])

cnt1 = 0

cnt2 = 0

ans = 0



while cnt1 < len(sorted1) and cnt2 < len(sorted2):

    if sorted1[cnt1][0] == sorted2[cnt2][0]:

        ans += sorted1[cnt1][1] * sorted2[cnt2][1]

        cnt1 += 1

        cnt2 += 1

    elif sorted1[cnt1][0] > sorted2[cnt2][0]:

        cnt2 += 1

    else:

        cnt1 += 1



print(ans)

n = int(eval(input()))

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



add1 = []

sub1 = []

for i in range(n):

    add1.append(a[i] + i)

    sub1.append(i - a[i])



dict1 = {}

dict2 = {}

for i in add1:

    if i in dict1:

        dict1[i] += 1

    else:

        dict1[i] = 1

for i in sub1:

    if i in dict2:

        dict2[i] += 1

    else:

        dict2[i] = 1



ans = 0

for k,v in list(dict1.items()):

    if k in dict2:

        ans += v * dict2[k]



print(ans)

n = int(eval(input()))
a = list(map(int, input().split()))
add1 = []
sub1 = []
for i in range(n):
    add1.append(a[i] + i)
    sub1.append(i - a[i])
dict1 = {}
dict2 = {}
for i in add1:
    if i in dict1:
        dict1[i] += 1
    else:
        dict1[i] = 1
for i in sub1:
    if i in dict2:
        dict2[i] += 1
    else:
        dict2[i] = 1
sorted1 = sorted(list(dict1.items()), key=lambda x: x[0])
sorted2 = sorted(list(dict2.items()), key=lambda x: x[0])
cnt1 = 0
cnt2 = 0
ans = 0
while cnt1 < len(sorted1) and cnt2 < len(sorted2):
    if sorted1[cnt1][0] == sorted2[cnt2][0]:
        ans += sorted1[cnt1][1] * sorted2[cnt2][1]
        cnt1 += 1
        cnt2 += 1
    elif sorted1[cnt1][0] > sorted2[cnt2][0]:
        cnt2 += 1
    else:
        cnt1 += 1
print(ans)

n = int(eval(input()))
a = list(map(int, input().split()))
add1 = []
sub1 = []
for i in range(n):
    add1.append(a[i] + i)
    sub1.append(i - a[i])
dict1 = {}
dict2 = {}
for i in add1:
    if i in dict1:
        dict1[i] += 1
    else:
        dict1[i] = 1
for i in sub1:
    if i in dict2:
        dict2[i] += 1
    else:
        dict2[i] = 1
ans = 0
for k, v in list(dict1.items()):
    if k in dict2:
        ans += v * dict2[k]
print(ans)

-sorted1 = sorted(list(dict1.items()), key=lambda x: x[0]) -sorted2 = sorted(list(dict2.items()), key=lambda x: x[0]) -cnt1 = 0 -cnt2 = 0 -while cnt1 < len(sorted1) and cnt2 < len(sorted2): -    if sorted1[cnt1][0] == sorted2[cnt2][0]: -        ans += sorted1[cnt1][1] * sorted2[cnt2][1] -        cnt1 += 1 -        cnt2 += 1 -    elif sorted1[cnt1][0] > sorted2[cnt2][0]: -        cnt2 += 1 -    else: -        cnt1 += 1 +for k, v in list(dict1.items()): +    if k in dict2: +        ans += v * dict2[k]