#include <iostream>
#include <vector>
using namespace std;
int main(){
	int n;
	while(cin>>n,n){
		vector<string> s;
		for(int i=0;i<n;++i){
			string str;
			cin>>str;
			s.push_back(str);
		}
		int max=0;
		for(int i=0;i<n;++i){//yoko
			int count=0;
			char before = s[i][0];
			if(s[i][0]=='1') ++count;
			for(int j=1;j<n;++j){
				if(s[i][j]=='1'){
					if(before=='1') ++count;
					else count = 1;
				}else count = 0;
				before=s[i][j];
			}
			if(max<count)max=count;
		}
		for(int i=0;i<n;++i){//tate
			int count=0;
			char before = s[0][i];
			if(s[0][i]=='1') ++count;
			for(int j=1;j<n;++j){
				if(s[i][j]=='1'){
					if(before=='1') ++count;
					else count = 1;
				}else count = 0;
				before=s[j][i];
			}
			if(max<count)max=count;
		}
		for(int i=0;i<n*2-1;++i){//migisita
			int count=0;
			bool flag=false;
			char before;
			for(int j=0;j<n;++j){
				if(i+j-n>=n) break;
				if(i+j-n<0) continue;
				if(flag==false){
					flag=true;
					before = s[j][i+j-n];
					if(s[j][i+j-n]=='1') ++count;
				}else{
					if(s[j][i+j-n]=='1'){
						if(before=='1') ++count;
						else count = 1;
					}else count = 0;
					before=s[j][i+j-n];
				}
			}
			if(max<count)max=count;
		}
		for(int i=0;i<n*2-1;++i){//hidarisita
			int count=0;
			bool flag=false;
			char before;
			for(int j=0;j<n;++j){
				if(i-j<0) break;
				if(i-j>=n) continue;
				if(flag==false){
					flag=true;
					before = s[j][i-j];
					if(s[j][i-j]=='1') ++count;
				}else{
					if(s[j][i-j]=='1'){
						if(before=='1') ++count;
						else count = 1;
					}else count = 0;
					before=s[j][i-j];
				}
			}
			if(max<count)max=count;
		}
		cout<<max<<endl;
	}
	return 0;
}