n=int(eval(input()))

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

k=[]

ans=0

for i in range(400005):

  k.append(0)

for i in range(n):

  if i-a[i]>=0:

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

  if a[i]+i<400005:

    k[a[i]+i]+=1

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

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

thing={}

ans=0

for i in range(n):

  if i-a[i] in thing:

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

  if i+a[i] in thing:

    thing[i+a[i]]+=1

  else:

    thing[i+a[i]]=1

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

n = int(eval(input()))
a = list(map(int, input().split()))
thing = {}
ans = 0
for i in range(n):
    if i - a[i] in thing:
        ans += thing[i - a[i]]
    if i + a[i] in thing:
        thing[i + a[i]] += 1
    else:
        thing[i + a[i]] = 1
print(ans)

-k = [] +thing = {} -for i in range(400005): -    k.append(0) -    if i - a[i] >= 0: -        ans += k[i - a[i]] -    if a[i] + i < 400005: -        k[a[i] + i] += 1 +    if i - a[i] in thing: +        ans += thing[i - a[i]] +    if i + a[i] in thing: +        thing[i + a[i]] += 1 +    else: +        thing[i + a[i]] = 1