#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std;
int n, ans, G[300][300][4];
const int mv[4][2] = { {-1,0},{0,-1},{-1,-1},{-1,1} };
inline bool nextChar(void) {
	char c = getchar();
	while (c != '1'&&c != '0')c = getchar();
	return c == '1';
}
signed main(void) {
	while (scanf("%d", &n) && n) {
		memset(G, 0, sizeof(G)), ans = 0;
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++) if (nextChar())
				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);
	}
}