#include <iostream>
#include <string>
#include <cstring>
using namespace std;
#define REP(i, n)           REPEAT(i, 0, n)
#define REPEAT(i, k, n)     for(int i = (k); i < ((k)+(n)); ++i)
template<class _T> _T MAX(_T p1,_T p2){return (p1>p2)?p1:p2;} 

int m[256][256];

void solve(int n){
    int t1[256], t2[256];
    int mx = 0;

    memset(t1,0,sizeof(t1));
    memset(t2,0,sizeof(t2));
    REP(y,n) REP(x,n){
        if(m[y][x]){
            mx = MAX(mx, ++t1[x]);
            mx = MAX(mx, ++t2[y]);
        } else {
            t1[x] = 0;
            t2[y] = 0;
        }
    }
    memset(t1,0,sizeof(t1));
    memset(t2,0,sizeof(t2));
    REP(y,n) REP(x,n){
        if(x == 0)   t1[(x-y+n)%n] = 0;
        if(x == n-1) t2[(x+y+n)%n] = 0;
        if(m[y][x]){
            mx = MAX(mx, ++t1[(x-y+n)%n]);
            mx = MAX(mx, ++t2[(x+y+n)%n]);
        } else {
            t1[(x-y+n)%n] = 0;
            t2[(x+y+n)%n] = 0;
        }
    }

    cout << mx << endl;
}

int main(){
    int n;
    while(cin >> n && n){
        for(int y = 0; y < n; y++){
            string s; cin >> s;
            for(int x = 0; x < n; x++) m[y][x] = s[x] - '0';
        }
        solve(n);
    }
    return 0;
}