program main
  implicit none
  integer i,p(20),N,ans,a,b
  read(*, *) N
  read(*, *) (p(i), i = 1,N)
  ans = 0
  do i= 2,N-1
    a = p(i)-p(i-1)
    b = p(i)-p(i+1)
    if(a*b<0) then
      ans = ans +1
    end if
  end do


  write(*, *) ans
end program main
