loop do
  n = gets.to_i
  break if n==0
  map = Array.new(n).map!{Array.new(n)}
  n.times do |i|
    map[i]=gets.chomp.split("")
  end
  ans =0
  n.times do |y|
    n.times do |x|
      if(map[y][x]=="1")
        dx=[0,1,1,-1]
        dy=[1,0,1,1]
        4.times do |i|
          nx = x + dx[i]
          ny = y + dy[i]
          c=1
          while(nx>=0&&ny>=0&&nx<n&&ny<n&&map[ny][nx]=="1")
            nx+=dx[i]
            ny+=dy[i]
            c+=1
          end
          ans = [ans,c].max
        end
      end
    end
  end
  puts ans
end