#include <iostream>

int getH(char** board, int n)
{
	int res = 0;
	for (int i=0; i<n; i++) {
		int count = 0;
		for (int j=0; j<n; j++) {
			if (board[i][j] == '0') count = 0;
			else {
				count++;
				if (count > res) res = count;
			}
		}
	}
	return res;
}

int getV(char** board, int n)
{
	int res = 0;
	for (int j=0; j<n; j++) {
		int count = 0;
		for (int i=0; i<n; i++) {
			if (board[i][j] == '0') count = 0;
			else {
				count++;
				if (count > res) res = count;
			}
		}
	}
	return res;
}

int getLD(char** board, int n)
{
	int res = 0;
	for (int i=0; i<n; i++) {
		int count = 0;
		for (int j=0; j<=i; j++) {
			if (board[j][i-j] == '0') count = 0;
			else {
				count++;
				if (count > res) res = count;
			}
		}
	}
	for (int i=0; i<n-1; i++) {
		int count = 0;
		for (int j=0; j<=i; j++) {
			if (board[n-1-i+j][n-1-j] == '0') count = 0;
			else {
				count++;
				if (count > res) res = count;
			}
		}
	}
	return res;
}

int getRD(char** board, int n)
{
	int res = 0;
	for (int i=0; i<n; i++) {
		int count = 0;
		for (int j=0; j<=i; j++) {
			if (board[j][n-1-i+j] == '0') count = 0;
			else {
				count++;
				if (count > res) res = count;
			}
		}
	}
	for (int i=0; i<n-1; i++) {
		int count = 0;
		for (int j=0; j<=i; j++) {
			if (board[n-1-i+j][j] == '0') count = 0;
			else {
				count++;
				if (count > res) res = count;
			}
		}
	}
	return res;
}

int main()
{
	int n;
	while (true) {
		std::cin >> n;
		if (n==0) break;
		char** board = new char*[n];
		for (int i=0; i<n; i++) board[i] = new char[n];
		for (int i=0; i<n; i++) {
			for (int j=0; j<n; j++) std::cin >> board[i][j];
		}
		int res = std::max( std::max(getH(board,n), getV(board,n)), std::max(getLD(board,n), getRD(board,n)) );
		std::cout << res << std::endl;
		for (int i=0; i<n; i++) delete[] board[i];
		delete[] board;
	}
	return 0;
}

