#include <iostream>
#include <stdlib.h>

using namespace std;

int d[8][2] = {
	{-1, -1},
	{-1, 0},
	{-1, 1},
	{0, -1},
	{0, 1},
	{1, -1},
	{1, 0},
	{1, 1}
};

int search(int **a, int x, int y, int n, int k)
{
	if(x < 0 || y < 0 || x == n || y == n || a[x][y] == 0){
		return 0;
	} else {
		return (search(a, (x+d[k][0]), (y+d[k][1]), n, k) + 1);
	}
}

int main(int argc, char **argv)
{
	int **a, n, i, j, k, tmp, c, cnt = 0;
	
	while(1){
		cin >> tmp;
		if(tmp == 0){
			break;
		}
		n = tmp;
		a = (int **)calloc(n, sizeof(int));
		for(i = 0; i < n; i++){
			a[i] = (int *)calloc(n, sizeof(int));
			for(j = 0; j < n; j++){
				scanf("%1d", &a[i][j]);
			}
		}
			
		for(i = 0, c = 0; i < n; i++){
			for(j = 0; j < n; j++){
				if(a[i][j] == 1){
					for(k = 0, tmp = 1; k < 8; k++, tmp = 1){
						tmp += search(a, i+d[k][0], j+d[k][1], n, k);			
						if(c < tmp){
							c = tmp;
						}
					}
				}
			}
		}
		
		cout << c << endl;
		for(i = 0; i < n; i++){
			free(a[i]);
		}
		free(a);
		n = 0;
	}
	
	return 0;
}