#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fr first
#define sc second
typedef pair<int, int> Pii;
typedef vector<int> Vi;
const int INF = (1<<25);
const int dx[]={1,0,1,-1}, dy[]={0,1,1,1};

int main() {
  int n;
  while(cin>> n, n) {
    char grid[256][256];
    int ans = 0;
    for(int i=0; i<n; i++) {
      for(int j=0; j<n; j++) {
	cin>> grid[i][j];
      }
    }

    for(int y=0; y<n; y++) {
      for(int x=0; x<n; x++) {
	if(grid[y][x] == '1') {
	  for(int i=0; i<4; i++) {
	    int nx=x+dx[i], ny=y+dy[i];
	    int cnt = 1;
	    while(nx >= 0 && ny >= 0 && nx < n && ny < n && grid[ny][nx] == '1') {
	      nx += dx[i]; ny += dy[i];
	      cnt++;
	    }
	    ans = max(ans, cnt);
	  }
	}
      }
    }

    cout<< ans<< endl;
  }
}