#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,j) for(int i=0;i<j;i++)
using namespace std;
int n;
int dx[]={1,1,-1,0},dy[]={0,1,1,1};
vector<string>V;
int cnt(int y,int x,int d){
    if(x<0||x>=n||y<0||y>=n)return 0;
    if(V[y][x]=='0')return 0;
    return cnt(y+dy[d],x+dx[d],d)+1;
}
int main(){

    while(cin>>n,n){
        V.clear();
        string str;
        int mx=-1;
        rep(i,n){
            cin>>str;
            V.push_back(str);
        }
        rep(i,n)
            rep(j,n)
                rep(k,4)mx=max(mx,cnt(i,j,k));

        cout<<mx<<endl;


    }
}