#include <bits/stdc++.h>
using namespace std;

int dfs(int y, int x, int dy, int dx, vector<vector<int>> const& v) {
    int n = v.size();
    if(y < 0 || n <= y || x < 0 || n <= x || v[y][x] == 0) {
        return 0;
    }
    return dfs(y+dy, x+dx, dy, dx, v) + 1;
}

int main() {
    int n;
    while(cin >> n, n) {
        vector<vector<int>> v(n, vector<int>(n));
        for(int i=0; i<n; ++i) {
            for(int j=0; j<n; ++j) {
                char c; cin >> c;
                v[i][j] = c - '0';
            }
        }
        int res = 0;
        for(int i=0; i<n; ++i) {
            for(int j=0; j<n; ++j) {
                if(v[i][j] == 1) {
                    res = max(res, dfs(i+1, j, 1, 0, v)+1);
                    res = max(res, dfs(i, j+1, 0, 1, v)+1);
                    res = max(res, dfs(i+1, j+1, 1, 1, v)+1);
                    res = max(res, dfs(i+1, j-1, 1, -1, v)+1);
                }
            }
        }
        cout << res << endl;
    }
}
