integer p(20)
read *,n
read *,(p(i),i=1,n)
k = 0
do i = 2, n-1
   if (p(i-1) < p(i) .and. p(i) < p(i+1)) then
      k = k + 1
   else if (p(i-1) > p(i) .and. p(i) > p(i+1)) then
      k = k + 1
   endif
enddo
print '(i0)',k
end