#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i,0,(n))
#define pb(n) push_back(n)
#define mp(n,m) make_pair(n, m)
#define all(r) r.begin(),r.end()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;


int main(){
	int n;
	while(cin>>n&&n){
		vector<string> s(n);
		rep(i, n) cin>>s[i];
		int ans = 0;
		for(int i = 0; i < n; i++){
			vi v(n, 0);
			v[0] = s[i][0]-'0';
			for(int j = 1; j < n; j++){
				if(s[i][j]=='1'){
					v[j]=v[j-1]+1;
					ans = max(ans, v[j]);
				}
			}
			vi u(n, 0);
			u[0] = s[0][i]-'0';
			for(int j = 1; j < n; j++){
				if(s[j][i]=='1'){
					u[j]=u[j-1]+1;
					ans = max(ans, u[j]);
				}
			}
			vi a(n, 0);
			a[0] = s[0][i]-'0';
			for(int j = 1; i-j>=0; j++){
				if(s[j][i-j]=='1'){
					a[j]=a[j-1]+1;
					ans = max(ans, a[j]);
				}
			}
			vi b(n, 0);
			b[0] = s[i][n-1] - '0';
			for(int j  =1; i+j < n; j++){
				if(s[i+j][n-1-j]=='1'){
					b[j] = b[j-1]+1;
					ans = max(ans, b[j]);
				}
			}
			vi c(n, 0);
			c[0] = s[0][i]-'0';
			for(int j  =1; i+j < n; j++){
				if(s[j][i+j] == '1'){
					c[j]=c[j-1]+1;
					ans=max(ans, c[j]);
				}
			}
			vi d(n, 0);
			d[0] = s[i][0]-'0';
			for(int j  =1; i+j <n; j++){
				if(s[i+j][j] == '1'){
					d[j] = d[j-1]+1;
					ans = max(ans, d[j]);
				}
			}
		}
		cout<<ans<<endl;


	}
}