local mce, mfl, msq, mmi, mma = math.ceil, math.floor, math.sqrt, math.min, math.max

local up = {}
local down = {}
local a = {}
local n = io.read("*n")
for i = 1, n do a[i] = io.read("*n") end
up[1], down[1] = 1, 1
for i = 1, n - 1 do
  if(a[i] < a[i + 1]) then
    down[i + 1] = mmi(down[i] + 1, up[i] + 1)
    up[i + 1] = mmi(down[i] + 1, up[i])
  elseif(a[i + 1] < a[i]) then
    down[i + 1] = mmi(down[i], up[i] + 1)
    up[i + 1] = mmi(down[i] + 1, up[i] + 1)
  else
    down[i + 1] = mmi(down[i], up[i] + 1)
    up[i + 1] = mmi(up[i], down[i] + 1)
  end
end
print(mmi(up[n], down[n]))
