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

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

		int longest = 0;
		for(int i = 0; i < n; i++) {
			int a = 0, b = 0;
			for(int j = 0; j < n; j++) {
				if(in[i][j] == '1') {
					a++;
					longest = max(a, longest);
				}
				else
					a = 0;
				if(in[j][i] == '1') {
					b++;
					longest = max(b, longest);
				}
				else
					b = 0;
			}
		}
		for(int i = -1 * n + 1; i < n; i++) {
			int a = 0, b = 0;
			for(int j = 0; j < n; j++) {
				if(i + j >= 0 && i + j < n && in[i + j][j] == '1') {
					a++;
					longest = max(a, longest);
				}
				else
					a = 0;
				if(i + j >= 0 && i + j < n && in[i + j][n - j - 1] == '1') {
					b++;
					longest = max(b, longest);
				}
				else
					b = 0;
			}
		}
		cout << longest << endl;
	}
}