program main
  implicit none
  integer :: i,j,n,m
  real(8), allocatable :: a(:)
  read(*,*) n
  allocate(a(n))
  read(*,*)  (a(i), i = 1, n)

  m = 0
  do i = 1,n
    do j = i+1,n
      if (abs(i-j)==a(i)+a(j)) then
        m = m+1
      end if
    end do
  end do
  deallocate(a)
  print '(i0)',m
end program main