while gets
    max_count=0
    arr=Array.new
    n=$_.to_i
    break if n==0
    n.times do
        arr<<gets.chomp.split(//).map(&:to_i)
    end
    
    #?¨?
    for y in 0...n
        count=0
        for x in 0...n
            if arr[y][x]==1
                count+=1
                max_count=count if max_count<count
                else
                count=0
            end
        end
    end
    
    #???
    for x in 0...n
        count=0
        for y in 0...n
            if arr[y][x]==1
                count+=1
                max_count=count if max_count<count
            else
                count=0
                break
            end
        end
    end
    
    #????????????
    for x in 0...n
        count=0
        for y in 0...n
            n.times do |i|
                if (x+i<n)&&(y+i<n)&&(arr[y+i][x+i]==1)
                    count+=1
                    max_count=count if max_count<count
                else
                    count=0
                    break
                end
            end
        end
    end
    
    for x in 0...n
        count=0
        for y in 0...n
            n.times do |i|
                if (x-i>=0)&&(y+i<n)&&(arr[y+i][x-i]==1)
                    count+=1
                    max_count=count if max_count<count
                else
                    count=0
                    break
                end
            end
        end
    end
    
    p max_count
end