from collections import defaultdict

n = int(eval(input()))

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

d = defaultdict(int)

for i in range(n):

  d[i+a[i]] += 1

ans = 0

for i in range(n):

  ans += d[i-a[i]]

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

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

d = [0]*n

for i in range(n):

  if i+a[i] < n: d[i+a[i]] += 1

ans = 0

for i in range(n):

  if i-a[i] >= 0: ans += d[i-a[i]]

print(ans)
from collections import defaultdict

n = int(eval(input()))
a = list(map(int, input().split()))
d = defaultdict(int)
for i in range(n):
    d[i + a[i]] += 1
ans = 0
for i in range(n):
    ans += d[i - a[i]]
print(ans)

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

-from collections import defaultdict - -d = defaultdict(int) +d = [0] * n -    d[i + a[i]] += 1 +    if i + a[i] < n: +        d[i + a[i]] += 1 -    ans += d[i - a[i]] +    if i - a[i] >= 0: +        ans += d[i - a[i]]