program main
  implicit none

  integer :: n, a(20), i, c = 0

  read(*,*)n
  read(*,*)(a(i), i = 1, n)
  
  do i = 2, n-1
    if ((a(i-1) > a(i)) .and. (a(i) > a(i+1))) then
      c = c + 1
    else if ((a(i+1) > a(i)) .and. (a(i) > a(i-1))) then
      c = c + 1
    end if
  end do
  write(*,*)c

end program main