n = int(eval(input()))

L_dict, R_dict = {}, {}

i = 0

for ipt in input().split():

    try:

        L_dict[i + int(ipt)] += 1

    except KeyError:

        L_dict[i + int(ipt)] = 1

    try:

        R_dict[i - int(ipt)] += 1

    except KeyError:

        R_dict[i - int(ipt)] = 1

    i += 1

cnt = 0

for Lk, Lv in list(L_dict.items()):

    try:

        cnt += R_dict[Lk] * Lv

    except KeyError:

        pass

print(cnt)
from collections import defaultdict

n = int(eval(input()))

L_dict, R_dict = defaultdict(int), defaultdict(int)

i = 0

for ipt in input().split():

    L_dict[i + int(ipt)] += 1

    R_dict[i - int(ipt)] += 1

    i += 1

cnt = 0

for Lk, Lv in list(L_dict.items()):

    try:

        cnt += R_dict[Lk] * Lv

    except KeyError:

        pass

print(cnt)
n = int(eval(input()))
L_dict, R_dict = {}, {}
i = 0
for ipt in input().split():
    try:
        L_dict[i + int(ipt)] += 1
    except KeyError:
        L_dict[i + int(ipt)] = 1
    try:
        R_dict[i - int(ipt)] += 1
    except KeyError:
        R_dict[i - int(ipt)] = 1
    i += 1
cnt = 0
for Lk, Lv in list(L_dict.items()):
    try:
        cnt += R_dict[Lk] * Lv
    except KeyError:
        pass
print(cnt)

from collections import defaultdict

n = int(eval(input()))
L_dict, R_dict = defaultdict(int), defaultdict(int)
i = 0
for ipt in input().split():
    L_dict[i + int(ipt)] += 1
    R_dict[i - int(ipt)] += 1
    i += 1
cnt = 0
for Lk, Lv in list(L_dict.items()):
    try:
        cnt += R_dict[Lk] * Lv
    except KeyError:
        pass
print(cnt)

+from collections import defaultdict + -L_dict, R_dict = {}, {} +L_dict, R_dict = defaultdict(int), defaultdict(int) -    try: -        L_dict[i + int(ipt)] += 1 -    except KeyError: -        L_dict[i + int(ipt)] = 1 -    try: -        R_dict[i - int(ipt)] += 1 -    except KeyError: -        R_dict[i - int(ipt)] = 1 +    L_dict[i + int(ipt)] += 1 +    R_dict[i - int(ipt)] += 1