#include <iostream>
#include <cstring>
using namespace std;
int n;
char t[256][256];
int res[4][256][256];
int d[4][2] = {
	{-1, 0},
	{-1. -1},
	{0, -1},
	{1, -1},
};
int main() {
	while (cin >> n, n) {
		for (int i = 0; i < n; i++) {
			cin >> t[i];
		}
		int result = 0;
		memset(res, 0, sizeof(res));
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < n; j++) {
				for (int k = 0; k < n; k++) {
					if ((j == 0 || k == 0 || (i == 3 && k == n - 1)) && t[j][k] == 1) {
						res[i][j][k] = 1;
					}
					else {
						int preX = k + d[i][0];
						int preY = j + d[i][1];
						if (t[j][k] == '1') {
							res[i][j][k] = res[i][preY][preX] + 1;
						}
					}
					result = max(result, res[i][j][k]);
					//cout << ' ' << result;
				}
				//cout << endl;
			}
		}
		cout << result << endl;
	}
}