n,*l=list(map(int,open(0).read().split()));d,a={},0

for i in range(n):d[i+l[i]]=d.get(i+l[i],0)+1;a+=d.get(i-l[i],0)

print(a)
_,*l=list(map(int,open(0).read().split()));d,a,i={},0,0

for h in l:d[i+h]=d.get(i+h,0)+1;a+=d.get(i-h,0);i+=1

print(a)
n, *l = list(map(int, open(0).read().split()))
d, a = {}, 0
for i in range(n):
    d[i + l[i]] = d.get(i + l[i], 0) + 1
    a += d.get(i - l[i], 0)
print(a)

_, *l = list(map(int, open(0).read().split()))
d, a, i = {}, 0, 0
for h in l:
    d[i + h] = d.get(i + h, 0) + 1
    a += d.get(i - h, 0)
    i += 1
print(a)

-n, *l = list(map(int, open(0).read().split())) -d, a = {}, 0 -for i in range(n): -    d[i + l[i]] = d.get(i + l[i], 0) + 1 -    a += d.get(i - l[i], 0) +_, *l = list(map(int, open(0).read().split())) +d, a, i = {}, 0, 0 +for h in l: +    d[i + h] = d.get(i + h, 0) + 1 +    a += d.get(i - h, 0) +    i += 1