#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int get(const vvi& a,int i,int j)
{
	if(i<0 || a.size()<=i || j<0 || a[i].size()<=j)
		return 0;
	return a[i][j];
}

int main()
{
	for(int n;cin>>n,n;){
		vs s(n);
		rep(i,n)
			cin>>s[i];
		vvi a(n,vi(n)),b=a,c=a,d=a;
		rep(i,n) rep(j,n)
			if(s[i][j]=='1'){
				a[i][j]=get(a,i-1,j)+1;
				b[i][j]=get(b,i,j-1)+1;
				c[i][j]=get(c,i-1,j-1)+1;
				d[i][j]=get(d,i-1,j+1)+1;
			}
		int res=0;
		rep(i,n) rep(j,n)
			res=max(res,max(max(a[i][j],b[i][j]),max(c[i][j],d[i][j])));
		cout<<res<<endl;
	}
	
	return 0;
}