#include <iostream>
using namespace std;

#define SIZE 257

int table[256][256];

enum {
	RIGHT_DOWN = 0,
	DOWN,
	LEFT_DOWN
};

int current_counts[SIZE][3]; //1ツ篠淞：ツ暗環置ツ、2ツ篠淞：ツ古シツつォ
int next_counts[SIZE][3];
int max_count = 0;

void init_counts() {
	for (int i = 0; i < SIZE; ++i) {
		for (int j = 0; j < 3; ++j) {
			current_counts[i][j] = next_counts[i][j] = 0;
		}
	}
}

void check_max(int expect) {
	if(expect > max_count) {
		max_count = expect;
	}
}

int main() {
	while (true) {
		int n;
		cin >> n;
		if(n == 0) {
			break;
		}
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				char o;

				cin >> o;
				table[i][j] = o - '0';
			}
		}

		init_counts();
		max_count = 0;
		int cont_vertical = 0;

		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				if(table[i][j] == 1) {
					cont_vertical++;

					next_counts[j][DOWN] = current_counts[j][DOWN] + 1;
					if(j+1 < n) {
						next_counts[j+1][RIGHT_DOWN] = current_counts[j][RIGHT_DOWN] + 1;
					}
					else {
						check_max(current_counts[j][RIGHT_DOWN] + 1);
					}
					if(j > 0) {
						next_counts[j-1][LEFT_DOWN] = current_counts[j][LEFT_DOWN] + 1;
					}
					else {
						check_max(current_counts[j][LEFT_DOWN] + 1);
					}
				}
				else {
					check_max(cont_vertical);
					cont_vertical = 0;
					for (int k = 0; k < 3; ++k) {
						check_max(current_counts[j][k]);
					}
				}
				for (int k = 0; k < 3; ++k) {
				}
			}
			for (int j = 0; j < n; ++j) {
				for (int k = 0; k < 3; ++k) {
					current_counts[j][k] = next_counts[j][k];
					next_counts[j][k] = 0;
				}
			}
		}
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < 3; ++j) {
				check_max(current_counts[i][j]);
			}
		}

		cout << max_count << endl;
	}
	return 0;
}