n = gets.to_i
a = (1..n).map { gets.to_i }
l = 1
k = 0
a.each_with_index do |x, i|
    next if i == 0
    next if x == a[i-1]
    if x > a[i-1]
        if k > 0
            k += 1
        else
            l = k.abs if l < k.abs
            k = 2
        end
    else
        if k < 0
            k -= 1
        else
            l = k.abs if l < k.abs
            k = -2
        end
    end
end
l = k.abs if l < k.abs
p l

