#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;

void _memset();
void _cin();
void check1();
int _check();

#define MAX_N 8000

int n;
char x[MAX_N][MAX_N];
string tate[MAX_N], yoko[MAX_N], naname1[MAX_N * 10], naname2[MAX_N * 10];

void _memset() {
	memset(x, '0', sizeof(x));
	for (int i = 0; i < MAX_N; i++) {
		tate[i] = "";
	}
	for (int i = 0; i < MAX_N; i++) {
		yoko[i] = "";
	}
	for (int i = 0; i < MAX_N * 10; i++) {
		naname1[i] = "";
	}
	for (int i = 0; i < MAX_N * 10; i++) {
		naname2[i] = "";
	}
}

void _cin(int p) {
	for (int i = 0; i < p; i++) {
		for (int j = 0; j < p; j++) {
			cin >> x[i][j];
		}
	}
}

void check1(int p) {
	for (int i = 0; i < p; i++) {
		for (int j = 0; j < p; j++) {
			tate[i] += x[i][j];
			yoko[j] += x[i][j];
			naname1[i + j] += x[i][j];
			naname2[p + i - j] += x[i][j];
		}
	}
}

int maxn;

int _check(int p) {
	maxn = 0;

	//tate.
	int chain = 0;
	for (int i = 0; i < p; i++) {
		chain = 0;
		for (int j = 0; j < tate[i].size(); j++) {
			if (tate[i][j] == '1') {
				chain++;
			}
			else {
				maxn = max(chain, maxn);
				chain = 0;
			}
		}
	}

	maxn = max(chain, maxn);

	//yoko.
	for (int i = 0; i < p; i++) {
		chain = 0;
		for (int j = 0; j < yoko[i].size(); j++) {
			if (yoko[i][j] == '1') {
				chain++;
			}
			else {
				maxn = max(chain, maxn);
				chain = 0;
			}
		}
	}

	maxn = max(chain, maxn);

	//naname1.
	for (int i = 0; i < p * 10; i++) {
		chain = 0;
		for (int j = 0; j < naname1[i].size(); j++) {
			if (naname1[i][j] == '1') {
				chain++;
			}
			else {
				maxn = max(chain, maxn);
				chain = 0;
			}
		}
	}

	maxn = max(maxn, chain);

	//naname2.
	for (int i = 0; i < p * 10; i++) {
		chain = 0;
		for (int j = 0; j < naname2[i].size(); j++) {
			if (naname2[i][j] == '1') {
				chain++;
			}
			else {
				maxn = max(chain, maxn);
				chain = 0;
			}
		}
	}

	maxn = max(chain, maxn);

	_memset();

	return maxn;
}

int main() {
	while (true) {
		cin >> n;
		if (n == 0) {
			break;
		}
		_cin(n);
		check1(n);
		cout << _check(n) << endl;
	}
	return 0;
}