local n = io.read("n")
local prev = io.read("n") -- 1
local cur = io.read("n") -- 2
local count = 0
for i=3,n do
    local next = io.read("n")
    if (prev < cur and cur < next) or (next < cur and cur < prev) then
        count = count + 1
    end
end
print(count)