#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

//v.erase(unique(v.begin(),v.end()),v.end());
int n;
int dx[]={1,0,1,-1};
int dy[]={0,1,1,1};
vector<vint> vv;
int foo(int a,int b,int c){
	int ret=0;
	int now=0;
	// return 0;
	while(0<=a&&a<n&&0<=b&&b<n){
		if(vv[a][b]==1){
			now++;
		}
		else{
			now=0;
		}
		// cout<<now<<endl;
		ret=max(ret,now);
		a+=dx[c];
		b+=dy[c];
	}
	return ret;
}




int main(){
	// vector<vint> vv;
	// int n;
	while(cin>>n,n){
		initvv(vv,n,n);
		rep(i,n){
			rep(j,n){
				char t;
				cin>>t;
				vv[i][j]=t-'0';
				// cout<<vv[i][j]<<" ";
			}
			// cout<<endl;
		}
		int ans=0;
		rep(i,n){
			ans=max(ans,foo(0,i,0));
			ans=max(ans,foo(i,0,1));
			ans=max(ans,foo(0,i,2));
			ans=max(ans,foo(i,0,2));
			ans=max(ans,foo(i,0,3));
			ans=max(ans,foo(n-1,i,3));
		}
		cout<<ans<<endl;
	}
	return 0;
}