#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) break;
		vector<string> field;
		for (int i = 0; i < n; i++) {
			string s; cin >> s;
			field.push_back(s);
		}

		// 横 
		int max_len = 0;
		for (int i = 0; i < n; i++) {
			int cur_len = 0;
			for (int j = 0; j < n; j++) {
				if (field[i][j] == '1') {
					cur_len++;
				} else {
					max_len = max(cur_len, max_len);
					cur_len = 0;
				}
			}
			max_len = max(cur_len, max_len);
		}

		// 縦
		for (int i = 0; i < n; i++) {
			int cur_len = 0;
			for (int j = 0; j < n; j++) {
				if (field[j][i] == '1') {
					cur_len++;
				} else {
					max_len = max(cur_len, max_len);
					cur_len = 0;
				}
			}
			max_len = max(cur_len, max_len);
		}

		// 斜め, 右上->左下
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				int cur_len = 0;
				for (int k = i, l = j; k < n && l < n; k++, l++) {
					if (field[k][l] == '1') {
						cur_len++;
					} else {
						max_len = max(cur_len, max_len);
						cur_len = 0;
					}
				}
				max_len = max(cur_len, max_len);
			}
		}

		// 斜め, 左上->右下
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				int cur_len = 0;
				for (int k = i, l = j; k < n && 0 <= l; k++, l--) {
					if (field[k][l] == '1') {
						cur_len++;
					} else {
						max_len = max(cur_len, max_len);
						cur_len = 0;
					}
				}
				max_len = max(cur_len, max_len);
			}
		}

		cout << max_len << endl;
	}
	return 0;
}