N = gets.chomp.to_i
PN = gets.chomp.split(' ').map(&:to_i)[0..N]

puts (0.upto(N-3).reduce(0) do |count, i|
  count += 1 if ( PN[i] < PN[i+1] && PN[i+1] < PN[i+2] ) || ( PN[i] > PN[i+1] && PN[i+1] > PN[i+2] )
  count
end)
