local function reada(n,m)m=m or 1 r={}for i=1,m do r[i]={}end for i=1,n do for j=1,m do r[j][i]=io.read"*n"end end return unpack(r)end
N=io.read"*n"
A=reada(N)

s=0
for i=1,N do
for j=i+A[i]+1,N do
	if(A[i]+A[j]==j-i)then s=s+1 end
end
end
print(s)