def kadomatsu a return a.uniq.size == 3 && (a[1] == a.max || a[1] == a.min) ? true : false end ans = 0 test_case = gets.to_i leng = gets.split.map(&:to_i) (test_case - 2).times{|i| ans += 1 if kadomatsu( [leng[i],leng[i + 1],leng[i + 2]] ) } puts ans