#include <iostream>
using namespace std;

int main() {
    int n;
    char D;

    while (cin >> n, n) {
        int h, v[2][257] = {0}, rd[2][257] = {0}, ld[2][257] = {0};
        int longest = 0;
        for (int i = 1; i <= n; i++) {
            int p = (i-1)&1, c = i&1;
            h = 0;
            for (int j = 1; j <= n; j++) {
                cin >> D;
                if (D == '1') {
                    h++;
                    if (longest < h) longest = h;
                    v[c][j] = v[p][j] + 1;
                    if (longest < v[c][j]) longest = v[c][j];
                    rd[c][j] = rd[p][j-1] + 1;
                    if (longest < rd[c][j]) longest = rd[c][j];
                    ld[c][j] = ld[p][j+1] + 1;
                    if (longest < ld[c][j]) longest = ld[c][j];
                }
                else {
                    h = 0;
                    v[c][j] = 0;
                    rd[c][j] = 0;
                    ld[c][j] = 0;
                }
            }
        }
        cout << longest << endl;
    }
    return 0;
}