#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip	;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1<<30;
int dp[300][300][4];
int main(){
	int n;
	int dx[]={0,-1,-1,-1};
	int dy[]={-1,-1,0,1};
	while(cin>>n,n){
		vector<string>in(n);
		rep(i,n)cin>>in[i];
		rep(i,n)rep(j,n)rep(k,4)if(in[i][j]=='1'){
			if(i==0&&j==0)dp[i][j][k]=1;
			else if(i==0&&k||j==0&&k<2||j==n-1&&k==3)dp[i][j][k]=1;
			else dp[i][j][k]=dp[i+dx[k]][j+dy[k]][k]+1;
		}else dp[i][j][k]=0;
		int out=0;
//		rep(i,n){rep(j,n)cout<<" "<<dp[i][j][0];cout<<endl;}
		rep(i,n)rep(j,n)rep(k,4)out=max(out,dp[i][j][k]);
		cout<<out<<endl;
	}
}