#include <iostream>
#include <vector>
#include <iomanip>

using namespace std;

int saiki(int y,int x,int dir,vector<vector<char> > &field,vector<vector<vector<int> > > &table,int count){
    if(table[y][x][dir] != -1) return count+table[y][x][dir];
    if(field[y][x] == '0') return count;
    int m;
    switch(dir){
    case 0:
        m= saiki(y+1,x,dir,field,table,count+1);
        break;
    case 1:
        m= saiki(y+1,x+1,dir,field,table,count+1);
        break;
    case 2:
        m= saiki(y,x+1,dir,field,table,count+1);
        break;
    case 3:
        m= saiki(y-1,x+1,dir,field,table,count+1);
        break;
    case 4:
        m= saiki(y-1,x,dir,field,table,count+1);
        break;
    case 5:
        m= saiki(y-1,x-1,dir,field,table,count+1);
        break;
    case 6:
        m= saiki(y,x-1,dir,field,table,count+1);
        break;
    case 7:
        m= saiki(y+1,x-1,dir,field,table,count+1);
        break;
    }
    table[y][x][dir] = m;
    return m;
}

int solve(vector<vector<char> > field){
    int n = field.size();
    //[y][x][dir]
    vector<vector<vector<int> > > v(n,vector<vector<int> >(n,vector<int>(8,-1)));

    for(int i=0;i<n;i++){
        for(int j=0;j<8;j++){
            v[i][0][j] = 0;
            v[i][n-1][j] = 0;
            v[0][i][j] = 0;
            v[n-1][i][j] = 0;
        }
    }
    int ret = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<8;k++){
                ret = max(saiki(i,j,k,field,v,0),ret);
            }
        }
    }
    return ret;
}

int main(){
    int n;
    while(cin >> n && n!= 0){
        vector<vector<char> > v(n+2,vector<char>(n+2,'0'));
        for(int i=1;i<n+1;i++){
            for(int j=1;j<n+1;j++){
                char c;
                cin >> c;
                if(c=='1')v[i][j] = '1';
            }
        }
        cout << solve(v) << endl;
    }
    return 0;
}