#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>
#include <complex>
#include <iostream>
#include <iterator>

using namespace std;

#define reep(i,f,t) for(int i=f ; i<int(t) ; ++i)
#define rep(i,n) reep(i, 0, n) 

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

typedef vector<double> vd;
typedef vector<vd> vvd;

int main()
{
	int n;
	while(scanf("%d", &n), n){
		char str[256];
		vector<string> table(n);
		rep(i, n){
			scanf("%s", str);
			table[i] = str;
		}
		
		int ans = 0;
		rep(i, n) rep(j, n){
			const int dy[] = {-1, -1, 0, 1};
			const int dx[] = {0, 1, 1, 1};
			rep(k, 4){
				int y = i, x = j;
				int cnt = 0;
				while(table[y][x] == '1'){
					++cnt;
					int py = y + dy[k], px = x + dx[k];
					if(py<0 || n<=py || px<0 || n<=px)
						break;
					y = py;
					x = px;
				}
				ans = max(ans, cnt);
			}
		}
		
		printf("%d\n", ans);
	}
	
	return 0;
}