#include <bits/stdc++.h>

using namespace std;

static inline int in(){ int x; scanf("%d", &x); return x; }

struct Solver {
  Solver(int n) : n(n) {}
  void read_input(){
    for (int i = 0; i < n; i++){
      char buf[512];
      scanf("%s", buf);
      for (int j = 0; j < n; j++){
        grid[i][j] = buf[j] - '0';
      }
    }
  }
  int get_max(){
    int maxi = 0;
    int L = n - 1;
    for (int i = 0; i < n; i++){
      maxi = max(maxi, scan(0, i, 1, 0));
      maxi = max(maxi, scan(0, i, 1, 1));
      maxi = max(maxi, scan(0, i, 1,-1));
      maxi = max(maxi, scan(i, 0, 0, 1));
      maxi = max(maxi, scan(i, 0, 1, 1));
      maxi = max(maxi, scan(i, L, 1,-1));
    }
    return maxi;
  }
  int scan(int x, int y, int dx, int dy){
    int maxi = 0;
    int v = 0;
    while (0 <= x && x < n && 0 <= y && y < n){
      v = v * grid[y][x] + grid[y][x];
      maxi = max(maxi, v);
      x += dx;
      y += dy;
    }
    return maxi;
  }

  int grid[255][255];
  int n;
};

int main()
{
  int n;
  while (n = in()){
    Solver solver(n);
    solver.read_input();
    printf("%d\n", solver.get_max());
  }

  return 0;
}