#include <iostream>
using namespace std;

int search(int x, int y, int k, int n, char** field) {
    int nx, ny;
    switch (k) {
    case 0:
        nx = x + 1;
        ny = y;
        break;
    case 1:
        nx = x + 1;
        ny = y + 1;
        break;
    case 2:
        nx = x;
        ny = y + 1;
        break;
    case 3:
        nx = x - 1;
        ny = y + 1;
        break;
    }
    if (0 <= nx && nx < n && 0 <= ny && ny < n && field[ny][nx] != '0') {
        return 1 + search(nx, ny, k, n, field);
    } else {
        return 1;
    }
}

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        char** field = new char* [n];
        for (int i = 0; i < n; i++) {
            field[i] = new char [n + 1];
        }
        for (int i = 0; i < n; i++) {
            cin >> field[i];
        }

        int max = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (field[i][j] == '0') {
                    continue;
                }
                for (int k = 0; k < 4; k++) {
                    int length = search(j, i, k, n, field);
                    if (max < length) {
                        max = length;
                    }
                }
            }
        }
        cout << max << endl;
        for (int i = 0; i < n; i++) {
            delete[] field[i];
        }
        delete[] field;
    }
}