program ordinary_number
  implicit none
  integer :: n, p(20), m, i
  p = 0
  m = 0
  read(*,*) n
  read(*,*) p(1:n)
  do i = 2, n-1
    if (p(i).eq.sum(p(i-1:i+1))-maxval(p(i-1:i+1))-minval(p(i-1:i+1))) m = m+1
  end do
  write(*,'(i0)') m
  stop
end program ordinary_number