#include<bits/stdc++.h>
using namespace std;
int n, ans, G[300][300][4];
int mv[4][2] = { { -1,0 },{ 0,-1 },{ -1,-1 },{ -1,1 } };
signed main(void) {
	while (scanf("%d", &n) && n) {
		memset(G, 0, sizeof(G)), ans = 0; getchar();
		for (int i = 1; i <= n; i++, getchar())
			for (int j = 1; j <= n; j++) if (getchar()-'0')
				for (int k = 0; k < 4; k++)
					G[i][j][k] = G[i + mv[k][0]][j + mv[k][1]][k] + 1,
					ans = ans < G[i][j][k] ? G[i][j][k] : ans;
		printf("%d\n", ans);
	}
}