#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int n,i,j,c,max_c;
	while(scanf("%d",&n),n)
	{
		const int OFFSET = 256,MAX_I=OFFSET,MAX_J=OFFSET*3;
		char a[MAX_I][MAX_J] = {0};
		for(i=0;i<n;++i)
			scanf("%s",&a[i][OFFSET]);
		max_c = c =0;
		for(j=OFFSET;j<MAX_J;++j)
			for(c=0,i=OFFSET;i<MAX_I;++i)
				(a[i][j]=='1') ? max_c=max(++c,max_c): c=0;
		for(i=OFFSET;i<MAX_I;++i)
			for(c=0,j=OFFSET;j<MAX_I;++j)
				(a[i][j]=='1') ? max_c=max(++c,max_c): c=0;
		for(i=0; i<MAX_I; ++i)
			for(c=0,j=0; j<MAX_J && i+j<=MAX_I; ++j)
				(a[i+j][j]=='1') ? max_c=max(++c,max_c): c=0;
		for(j=0; j<MAX_J; ++j)
			for(c=0,i=0;i<MAX_I; ++i)
			{
				if( j-i>=0)
					(a[i][j-i]=='1') ? max_c=max(++c,max_c): c=0;
			}
		printf("%d\n",max_c);
	}
	return 0;
}