// 2012/11/19 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;

		if(n==0)
			break;

		char G[257][257];
		for(int y=1; y<=n; y++){
			for(int x=1; x<=n; x++){
				cin >> G[y][x];
			}
		}

		int dp[4][257][257];
		for(int i=0; i<4; i++){
			for(int y=0; y<=n+1; y++){
				for(int x=0; x<=n+1; x++){
					dp[i][y][x] = 0;
				}
			}
		}

		int dp_max = 0;

		for(int y=1; y<=n; y++){
			for(int x=1; x<=n; x++){
				if(G[y][x]=='1'){
					dp[0][y][x] = dp[0][y-1][x]+1;
					dp[1][y][x] = dp[1][y][x-1]+1;
					dp[2][y][x] = dp[2][y-1][x-1]+1;
					dp[3][y][x] = dp[3][y-1][x+1]+1;

					for(int i=0; i<4; i++){
						if(dp[i][y][x]>dp_max){
							dp_max = dp[i][y][x];
						}
					}
				}
			}
		}

		cout << dp_max << endl;
	}

	return 0;
}