   program abc166e
      implicit none
      integer(8)::n
      integer(8),allocatable::a(:)
      integer(8)::ans=0

         read *, n
         allocate(a(n))
         read *, a

         call abs_tall(1_8)

         print *, ans
         stop

   contains

      recursive subroutine abs_tall(k)
         implicit none
         integer(8),intent(in)::k
         integer(8)::i

            do i=k,n
               if ( abs(i-k)==a(i)+a(k) ) ans=ans+1
            end do

            if (k==n-1) return
            call abs_tall(k+1)

      end subroutine abs_tall

   end program abc166e