require 'pp'

N = readline.chomp.to_i
PI = readline.chomp.split.map(&:to_i)

ans = 0
(PI.size-2).times do |i|
  if PI[i] < PI[i+1] and PI[i+1] < PI[i+2]
    ans += 1
  elsif PI[i] > PI[i+1] and PI[i+1] > PI[i+2]
    ans += 1
  end
end

puts ans
