#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define fi first
#define se second
using namespace std;


signed main(){
    int n;
    while(cin >> n, n){
        int MAX = 0;
        vector<string> d(256);
        rep(i, 0, n) cin >> d[i];
        rep(i ,0, n){
            rep(j, 0, n){
                if(d[i][j] != '1') break;
                if(j == n - 1) MAX = n;
            }
        }
        rep(i, 0, n){
            rep(j, 0, n){
                if(d[j][i] != '1') break;
                if(j == n - 1) MAX = n;
            }
        }
        rep(i, 0, n){
            int l = n - i;
            rep(j, 0, l){
                if(d[i + j][j] != '1') break;
                if(j == l - 1) MAX = max(MAX, l);
            }
        }
        rep(i, 0, n){
            int l = n - i;
            rep(j, 0, l){
                if(d[j][i + j] != '1') break;
                if(j == l - 1) MAX = max(MAX, l);
            }
        }
        rep(i, 0, n){
            int l = i + 1;
            rep(j, 0, l){
                if(d[i - j][j] != '1') break;
                if(j == l - 1) MAX = max(MAX, l);
            }
        }
        rep(i, 0, n){
            int l = n - i;
            rep(j, 0, l){
                if(d[i + j][n - 1 - j] != '1') break;
                if(j == l - 1) MAX = max(MAX, l);
            }
        }
        cout << MAX << endl;
    }
}