program em
implicit none
integer::N
integer,allocatable,dimension(:)::A
integer::i,j
integer(16)::ans=0
read*,N
allocate(A(N))
read*,A
do i=1,N-1
  do j=i+1,N
    if(abs(j-i)==A(i)+A(j))ans=ans+1
  end do
end do
print"(I0)",ans
end program em