from collections import defaultdict



N = int(eval(input()))

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



ans = 0



R = defaultdict(int) 

#R= defaultdict(lambda:0) 



for i ,Ai in enumerate(A,1):

  R[i+Ai]+=1



L = defaultdict(int) 

for j ,Aj in enumerate(A,1):

  L[j-Aj]+=1



for i in R:

  ans+=R.get(i,0)*L.get(i,0)



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

la = [int(i) for i in input().split()]



ia = {}

pair = 0

for j, a in enumerate(la):

  ia[j + a] = ia.get(j + a, 0) + 1



for j, a in enumerate(la): 

  pair += ia.get(j - a, 0)



print(pair)

from collections import defaultdict

N = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
R = defaultdict(int)
# R= defaultdict(lambda:0)
for i, Ai in enumerate(A, 1):
    R[i + Ai] += 1
L = defaultdict(int)
for j, Aj in enumerate(A, 1):
    L[j - Aj] += 1
for i in R:
    ans += R.get(i, 0) * L.get(i, 0)
print(ans)

n = int(eval(input()))
la = [int(i) for i in input().split()]
ia = {}
pair = 0
for j, a in enumerate(la):
    ia[j + a] = ia.get(j + a, 0) + 1
for j, a in enumerate(la):
    pair += ia.get(j - a, 0)
print(pair)

-from collections import defaultdict - -N = int(eval(input())) -A = list(map(int, input().split())) -ans = 0 -R = defaultdict(int) -# R= defaultdict(lambda:0) -for i, Ai in enumerate(A, 1): -    R[i + Ai] += 1 -L = defaultdict(int) -for j, Aj in enumerate(A, 1): -    L[j - Aj] += 1 -for i in R: -    ans += R.get(i, 0) * L.get(i, 0) -print(ans) +n = int(eval(input())) +la = [int(i) for i in input().split()] +ia = {} +pair = 0 +for j, a in enumerate(la): +    ia[j + a] = ia.get(j + a, 0) + 1 +for j, a in enumerate(la): +    pair += ia.get(j - a, 0) +print(pair)