N = gets.to_i
ps = gets.split.map(&:to_i)
count = 0
0.upto(ps.size - 3) do |i|
  if (ps[i] < ps[i+1] && ps[i+1] < ps[i+2]) || (ps[i] > ps[i+1] && ps[i+1] > ps[i+2])
    count += 1
  end
end
puts count
