loop do
  n = gets.to_i
  break if n.zero?
  board = n.times.map { gets.chomp }
  check = lambda do |x, y|
    0 <= x && x < n && 0 <= y && y < n && board[y][x] == ?1
  end
  r = 0
  n.times do |j|
    n.times do |i|
      [[-1, 0], [-1, 1], [0, 1], [1, 1]].each do |d|
        unless check[i-d[0], j-d[1]]
          x, y, c = i, j, 0
          x, y, c = x+d[0], y+d[1], c+1 while check[x, y]
          r = c if c > r
        end
      end
    end
  end
  p r
end