class Array
    def max_length
        l = 0
        m = 0
        each do |x|
            if x == 1
                l += 1
                m = l if l > m
            else
                l = 0
            end
        end
        m
    end
end

loop do
    n = gets.to_i
    break if n == 0

    a = (1..n).map { gets.split("").map(&:to_i) }
    m = 0

    (a + a.transpose).each do |r|
        l = r.max_length
        m = l if l > m
    end

    (0..n-1).to_a.product((0..n-1).to_a).group_by{|i, j| i + j}.values.each do |ijs|
        r = ijs.map{|i, j| a[i][j]}
        l = r.max_length
        m = l if l > m
    end

    (0..n-1).to_a.product((0..n-1).to_a).group_by{|i, j| i - j}.values.each do |ijs|
        r = ijs.map{|i, j| a[i][j]}
        l = r.max_length
        m = l if l > m
    end

    p m
end