def rotate90 array
  length = array.size
  rotated = Array.new(length).map{Array.new(length)}
  for y in 0...length
    for x in 0...length
      rotated[x][length - 1 - y] = array[y][x]
    end
  end
  rotated
end

def solveInRowColumn array
  n = array.size
  maxLengthInRow = -1
  maxLengthInColumn = -1
  n.times do |j|
    currentInRow = 0
    currentInColumn = 0
    maxInRow = 0
    maxInColumn = 0
    n.times do |i|
      #横
      if array[j][i] == 1
        if (i > 0 && array[j][i - 1] == 1) || i == 0
          currentInRow += 1
        else
          currentInRow = 1
        end
        maxInRow = [maxInRow, currentInRow].max
      end
      #縦
      if array[i][j] == 1
        if(i > 0 && array[i - 1][j] == 1) || i == 0
          currentInColumn += 1
        else
          currentInColumn = 1
        end
        maxInColumn = [maxInColumn, currentInColumn].max
      end
    end
    #全体での最大値更新
    maxLengthInRow = [maxInRow, maxLengthInRow].max
    maxLengthInColumn = [maxInColumn, maxLengthInColumn].max
  end
  [maxLengthInRow, maxLengthInColumn].max
end

def solveToDiagonal array
  n = array.size
  maxLength = -1
  n.times do |i|
    current = 0
    max = 0
    i.downto(0) do |j|
      if array[i - j][j] == 1
        if((i > 0 && j >= 0) && array[i -j - 1][j + 1] == 1) || i - j == 0
          current += 1
        else
          current = 1
        end
        max = [max, current].max
      end
    end
    maxLength = [max, maxLength].max
  end
  maxLength
end

while (n = $stdin.gets.to_i) != 0
  grid = Array.new
  n.times do
    grid << $stdin.gets.chomp.split("").map(&:to_i)
  end
  p [solveInRowColumn(grid), solveToDiagonal(grid), solveToDiagonal(grid.reverse!().each{|r| r.reverse!}), solveToDiagonal(rotate90(grid)), solveToDiagonal(rotate90(grid.reverse!().each{|r| r.reverse!}))].max
end