def main()
        stdin = $stdin.readlines.map {|i| i.chomp() }
        num = stdin[0]
        elem = stdin[1].split(" ").map {|i| i.to_i }
        base_p3_index = 2
        count = 0
        while base_p3_index <= elem.length-1
                if (elem[base_p3_index-2]<elem[base_p3_index-1]) == (elem[base_p3_index-1]<elem[base_p3_index])
                        count += 1
                end
                base_p3_index+=1
        end
        print(count)
end

main()