#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
char board[300][300]={{0}};

int n;
int main(){
	while(cin>>n,n){
		pair<pii,pii> dp[300][300];
		memset(dp, 0, sizeof(dp));
		int ans = 0;
		for(int i =1;i <=n;i++){
			for(int j =1;j <=n;j++){
				cin>>board[i][j];
				if(board[i][j]=='1'){
					dp[i][j].first.first =1;
					dp[i][j].first.second=1;
					dp[i][j].second.first =1;
					dp[i][j].second.second=1;
				}
			}
		}
		for(int i =1;i <=n;i++){
			for(int j =1;j <=n;j++){
				if(board[i][j]=='1'){
					int x = dp[i][j].first.first =dp[i][j-1].first.first+1;
					int y = dp[i][j].first.second=dp[i-1][j].first.second+1;
					int z = dp[i][j].second.first =dp[i-1][j-1].second.first+1;
					int r = dp[i][j].second.second=dp[i-1][j+1].second.second+1;
					//cout <<x<<" "<<y<<" "<<" "<<z<<" "<<r<<endl;
					int t1 =max(x,y);
					int t2 =max(z,r);
					ans =max(ans,max(t1,t2));
				}
			}
		}
		cout <<ans<<endl;
	}
	return 0;
}