#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int n;
	int MAX,sum;
	
	while(cin >> n && n){
		MAX = 0;
		
		char p[n*n+1];
		rep(i,n*n){cin >> p[i];p[i]-='0';}
		rep(i,n){
			sum = 0;
			rep(j,n)sum += p[i*n+j];
			MAX = max(sum,MAX);
		}
		rep(i,n){
			sum = 0;
			rep(j,n)sum += p[i+j*n];
			MAX = max(sum,MAX);
		}
		rep(i,n){
			sum = 0;
			rep(j,n-i)sum += p[i+j*(n+1)];
			MAX = max(sum,MAX);
		}
		rep(i,n){
			sum = 0;
			rep(j,n-i)sum += p[(n-1-i)+j*(n-1)];
			MAX = max(sum,MAX);
		}
		
		rep(i,n){
			sum = 0;
			rep(j,n-i)sum += p[n*n-1-i-j*(n+1)];
			MAX = max(sum,MAX);
		}
		
		rep(i,n){
			sum = 0;
			rep(j,i+1)sum += p[n*(n-1)+i-j*(n-1)];
			MAX = max(sum,MAX);
		}
		cout << MAX << endl;
	}
}