#include <iostream>
#include <algorithm>

using namespace std;

const int MAX_N = 260;
int n;
string grid[MAX_N];
int max_len;
int memo[MAX_N][MAX_N][4];

const int dx[] = {-1, 0, 1, 1};
const int dy[] = {1, 1, 1, 0};

int rec(int y, int x, int d)
{
    if (memo[y][x][d] >= 0)
        return memo[y][x][d];

    int nx = x + dx[d];
    int ny = y + dy[d];

    if (nx < 0 || nx >= n || ny < 0 || ny >= n)
        return 1;
    if (grid[ny][nx] == '0')
        return 1;

    return memo[y][x][d] = (rec(ny, nx, d) + 1);
}

int main()
{
    while (cin >> n, n) {
        max_len = 0;
        for (int i = 0; i < n; i++) 
            cin >> grid[i];

        for (int i = 0; i <= n; i++)
            for (int j = 0; j <= n; j++)
                for (int k = 0; k < 4; k++)
                    memo[i][j][k] = -1;

        for (int y = 0; y < n; y++) 
            for (int x = 0; x < n; x++) 
                if (grid[y][x] == '1') {
                    for (int k = 0; k < 4; k++) {
                        int nx = max_len * dx[k] + x;
                        int ny = max_len * dy[k] + y;
                        if (nx < 0 || nx >= n || ny < 0 || ny >= n)
                            continue;
                        if (grid[ny][nx] != '1')
                            continue;
                        max_len = max(max_len, rec(y, x, k));
                    }
                }

        cout << max_len << endl;
    }

    return 0;
}