#include <iostream>
#include <vector>

using namespace std;

int N;
int Max;
vector< vector<char> > Field;

void DFS_right(int y, int x, int count)
{
	if(Max < count)
	{
		Max = count;
	}
	if(0 <= x && x < N && 0 <= y && y < N && Field[y][x] == '1')
	{
		DFS_right(y, x + 1, count + 1);
	}	
}

void DFS_down(int y, int x, int count)
{
	if(Max < count)
	{
		Max = count;
	}
	if(0 <= x && x < N && 0 <= y && y < N && Field[y][x] == '1')
	{
		DFS_down(y + 1, x, count + 1);
	}	
}

void DFS_rightdown(int y, int x, int count)
{
	if(Max < count)
	{
		Max = count;
	}
	if(0 <= x && x < N && 0 <= y && y < N && Field[y][x] == '1')
	{
		DFS_rightdown(y + 1, x + 1, count + 1);
	}	
}

void DFS_leftdown(int y, int x, int count)
{
	if(Max < count)
	{
		Max = count;
	}
	if(0 <= x && x < N && 0 <= y && y < N && Field[y][x] == '1')
	{
		DFS_leftdown(y + 1, x - 1, count + 1);
	}	
}

void solve()
{
	while(cin >> N, N)
	{
		Field.resize(N);
		for(int i = 0; i < N; ++i)
		{
			Field[i].resize(N);
			for(int j = 0; j < N; ++j)
			{
				cin >> Field[i][j];
			}
		}

		Max = 0;
		for(int i = 0; i < N; ++i)
		{
			for(int j = 0; j < N; ++j)
			{
				if(Field[i][j] == '1')
				{
					DFS_right(i, j + 1, 1);
					DFS_down(i + 1, j, 1);
					DFS_rightdown(i + 1, j + 1, 1);
					DFS_leftdown(i + 1, j - 1, 1);
				}
			}
		}
		cout << Max << endl;
	}
}

int main()
{
	solve();
	return(0);
}