import scala.reflect.ClassTag

object Main extends App {
  import scala.io.StdIn.{readLine}
  solve(readLine().toInt)
  class Grid[T:ClassTag](val size:Int, default:() ⇒ T){
    private val defaultValue = default()
    private val mArray = Array.tabulate(size){_ ⇒ Array.tabulate(size){_ ⇒ default()}}
    def apply(x:Int, y:Int):T = mArray(y)(x)
    def update(x:Int, y:Int, value:T) = mArray(y)(x) = value
    def getOrDefault(x:Int, y:Int) = (0 until size).contains(x) && (0 until size).contains(y) match{
      case true ⇒ mArray(y)(x)
      case _ ⇒ defaultValue
    }
  }
  object Grid{
    def apply[T:ClassTag](size:Int, default:() ⇒ T):Grid[T] = new Grid(size, default)
  }
  class MaxValues(var up:Int = 0, var left:Int = 0, var leftUp:Int = 0, var rightUp:Int = 0) {
    def max:Int = List(up, left, leftUp, rightUp).max
  }
  object MaxValues{
    def apply() = new MaxValues()
  }
  def solve(n:Int):Unit = {
    if (n == 0) return
    val grid = Grid(n, () ⇒ 0)
    val maxGrid = Grid(n, MaxValues.apply)
    for (y ← 0 until n){
      readLine().zipWithIndex.foreach{case (c, x) ⇒
        grid(x, y) = c.asDigit
      }
    }
    println((for (y <- 0 until n; x ← 0 until n) yield {
      grid(x, y) match{
        case 1 ⇒ {
          maxGrid(x, y).left = maxGrid.getOrDefault(x - 1, y).left + 1
          maxGrid(x, y).leftUp = maxGrid.getOrDefault(x - 1, y - 1).leftUp + 1
          maxGrid(x, y).up = maxGrid.getOrDefault(x, y - 1).up + 1
          maxGrid(x, y).rightUp = maxGrid.getOrDefault(x + 1, y - 1).rightUp + 1
        }
        case _ ⇒
      }
      maxGrid(x, y).max
    }).max)
    solve(readLine().toInt)
  }
}

