#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
using namespace std;

const int dy[8] = {-1,-1,0,1,1,1,0,-1}, dx[8] = {0,1,1,1,0,-1,-1,-1};

int main(){
	int N;
	char fld[255][255];
	while(cin>>N,N){
		for(int i=0;i<N;i++)for(int j=0;j<N;j++) scanf(" %c",&fld[i][j]);
		int ans = 0;
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				for(int d=0;d<8;d++){
					int t = 0;
					for(;;t++){
						int ny = i+dy[d]*t, nx = j+dx[d]*t;
						if(ny<0 || N<=ny || nx<0 || N<=nx || fld[ny][nx]=='0') break;
					}
					ans = max(ans,t);
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}