integer :: n,p(20)
integer :: i,ans

read*,n
read*,p(1:n)

ans = 0

do i = 2,n-1
  if( (p(i-1)<p(i) .and. p(i)<p(i+1)) .or.&
      (p(i-1)>p(i) .and. p(i)>p(i+1))) ans = ans + 1
end do
print*,ans
end program
