#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
string map[300];
signed main() {
	int n;
	while (cin >> n, n) {
		for (int i = 0; i < n; i++)cin >> map[i];
		int ans = 0;
		for (int x = 0; x < n; x++) {
			for (int y = 0; y < n; y++) {
				if (map[x][y] == '0')continue;
				int x1 = x, y1 = y;
				for (int i = -1; i <= 1; i++) {
					for (int j = -1; j <= 1; j++) {
						x1 = x; y1 = y;
						if (i == 0 && j == 0)continue;
						int cnt = 1;
						while (x1 + i >= 0 && x1 + i < n && y1 + j >= 0 && y1 + j < n) {
							if (map[x1 + i][y1 + j] != '1') goto heaven;
							x1 += i; y1 += j; cnt++;
						}
					heaven:
						ans = max(ans, cnt);
					}
				}
			}
		}
		cout << ans << endl;
	}
}
