N = int(eval(input()))

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

ans = 0

dic = {}

for i in range(1,N):

  x = i-A[i]

  if x<0:

    continue

  else:

    if x in dic:

      dic[x]+=1

    else:

      dic[x]=1

if A[0] in dic:

  ans+=dic[A[0]]

for i in range(1,N):

  x = i+A[i]

  

  if i-A[i] in dic:

    dic[i-A[i]]-=1

    

  if x in dic:

    ans+=dic[x]

  

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

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

ans = 0

l = [0]*(3*10**5+10)

for i in range(1,N):

  x = i-A[i]

  if x<0:

    continue

  else:

    l[x]+=1

if A[0]<=2*10**5:

  ans+=l[A[0]]

for i in range(1,N):

  x = i+A[i]

  if x<0:

    continue

  if x>2*10**5:

    continue

  

  if i-A[i]>=0:

    l[i-A[i]]-=1

  ans+=l[x]

  

print(ans)

N = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
dic = {}
for i in range(1, N):
    x = i - A[i]
    if x < 0:
        continue
    else:
        if x in dic:
            dic[x] += 1
        else:
            dic[x] = 1
if A[0] in dic:
    ans += dic[A[0]]
for i in range(1, N):
    x = i + A[i]
    if i - A[i] in dic:
        dic[i - A[i]] -= 1
    if x in dic:
        ans += dic[x]
print(ans)

N = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
l = [0] * (3 * 10**5 + 10)
for i in range(1, N):
    x = i - A[i]
    if x < 0:
        continue
    else:
        l[x] += 1
if A[0] <= 2 * 10**5:
    ans += l[A[0]]
for i in range(1, N):
    x = i + A[i]
    if x < 0:
        continue
    if x > 2 * 10**5:
        continue
    if i - A[i] >= 0:
        l[i - A[i]] -= 1
    ans += l[x]
print(ans)

-dic = {} +l = [0] * (3 * 10**5 + 10) -        if x in dic: -            dic[x] += 1 -        else: -            dic[x] = 1 -if A[0] in dic: -    ans += dic[A[0]] +        l[x] += 1 +if A[0] <= 2 * 10**5: +    ans += l[A[0]] -    if i - A[i] in dic: -        dic[i - A[i]] -= 1 -    if x in dic: -        ans += dic[x] +    if x < 0: +        continue +    if x > 2 * 10**5: +        continue +    if i - A[i] >= 0: +        l[i - A[i]] -= 1 +    ans += l[x]