#include<cstdio>
#include<cstring>
#include<cstdlib>
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) { ans = 0; getchar();
	for (int i = 1; i <= n; i++, getchar())
		for (int j = 1; j <= n; j++)
			if (G[i][j][0] = G[i][j][1] = G[i][j][2] = G[i][j][3] = 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);
	}
}