while true
    n = gets.to_i
    break if n == 0
    arr, arr2, arr3 = [], [], []
    n.times{
        arr << gets.chomp
        arr2 << arr.last.split("")
    }
    max = 0
    arr.each{|str| str.split('0').each{|item| max = item.length if max < item.length}}
    arr2.transpose.each{|ar| ar.join.split('0').each{|item| max = item.length if max < item.length}}
    0.upto(n-1){|y|
        temp = []
        (y+1).times{|i| temp << arr[y-i][i]}
        arr3 << temp
    }
    1.upto(n-1){|j|
        temp = []
        (n - j).times{|i| temp << arr[n-1-i][i+j]}
        arr3 << temp
    }
    arr3.each{|ar| ar.join.split('0').each{|item| max = item.length if max < item.length}}
    puts max
end
