#include <iostream>
using namespace std;

int n;
char grid[255][255];
int dx[] = {1,0,1,-1};
int dy[] = {0,1,1,1};

int solv(int sx, int sy) {
	int res = 0;
	for (int i=0; i<4; ++i) {
		int cnt = 0, x = sx, y = sy;
		while (0 <= x && x < n && 0 <= y && y < n) {
			cnt = (grid[y][x] == '1' ? cnt+1 : 0);
			res = max(res, cnt);
			x += dx[i];
			y += dy[i];
		}
	}
	return res;
}

int main() {
	ios::sync_with_stdio(false);
	while (cin >> n, n) {
		char c;
		for (int i=0; i<n*n; ++i) {
			cin >> grid[i/n][i%n];
		}
		int res = 0;
		for (int i=0; i<n; ++i) {
			res = max(max(res, solv(0, i)), max(solv(n-1, i), solv(i, 0)));
		}
		cout << res << endl;
	}
	return 0;
}