#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen ("testcase.grid2", "r", stdin );
	string str = "";
	int n;

	while (getline (cin, str ) ) {
		stringstream ssn(str);
		ssn >> n;
		
		if (n == 0 ){
			break;
		} // end if

		vector <vector <int> > grid (n, vector <int> (n, 0 ) );
 
		int i,j,k;

		for (i = 0; i < n; ++i ){
			getline (cin, str );
			for (j = 0; j < n; ++j ){
				grid[i][j] = str[j] - '0';
			} // end for
		} // end for

		int res = 0;
		int sum = 0;
		bool found = false;

		for (i = 0; i < n; ++i ){
			sum = 0;
			found = false;

			for (j = 0; j < n; ++j ){
				if (grid[i][j] == 1 ){
					if (!found ){
						sum = 0;
						found = true;
					} // end if
					++sum;
				}else{
					res = max (res, sum );
					found = false;
					sum = 0;
				} // end if
			} // end for
			res = max (res, sum );
		} // end for

		for (j = 0; j < n; ++j){
			sum = 0;
			found = false;

			for (i = 0; i < n; ++i ){
				if (grid[i][j] == 1){
					if (!found ){
						sum = 0;
						found = true;
					} // end if
					++sum;
				}else{
					res = max (res, sum );
					found = false;
					sum = 0;
				} // end if
			} // end for
			res = max (res, sum );
		} // end for

		for (k = -n + 1; k < n; ++k){
			sum = 0;
			found = false;
			int prev_i = -1000;
			int prev_j = -1000;

			for (i = 0; i < n; ++i ){
				for (j = 0; j < n; ++j ){
					if (i - j == k ){
						if (grid[i][j] == 1 ){
							if (!found ){
								sum = 1;
								found = true;
							}else{
							 	if (i == prev_i + 1 
								 && j == prev_j + 1 ){
									++sum;
								}else{
									sum = 0;
									found = false;
								} // end if
							} // end if
							prev_i = i;
							prev_j = j;
						}else{
							res = max (res, sum );
							sum = 0;
							found = false;
						} // end if
					} // end if
				} // end for
			} // end for
			if (found ){
				res = max (res, sum );
			} // end if
		} // end for

		for (k = 0; k <= 2*(n-1); ++k){
			sum = 0;
			found = false;
			int prev_i = 1000;
			int prev_j = 1000;

			for (i = 0; i < n; ++i){
				for (j = 0; j < n; ++j){	
					if (i + j == k ){
						if (grid[i][j] == 1 ){
							if (!found ){
								sum = 1;
								found = true;
							}else{
							 	if (i == prev_i + 1 
								 && j == prev_j - 1 ){
									++sum;
								}else{
									sum = 0;
									found = false;
								} // end if
							} // end if
							prev_i = i;
							prev_j = j;
						}else{
							res = max (res, sum );
							sum = 0;
							found = false;
						} // end if
					} // end if
				} // end for
			} // end for
			if (found ){
				res = max (res, sum );
			} // end if
		} // end for	

		cout << res << endl;	
	} // end loop

		
	return 0;
}