#include <iostream>
using namespace std;

char map[255][255];

int dire4[][2] = {
    {1, 0}, {-1, 1}, {0, 1}, {1, 1}, 
    //{-1, -1}, {0, -1}, {1, -1}, {-1, 0}
};

int main(){
    int n;
    while(1){
        cin >> n;
        if(n == 0) break;

        for(int y = 0;y < n;y++) {
            for(int x = 0;x < n;x++) {
                cin >> map[y][x];
            }
        }

        int ans = 0;
        for(int y = 0;y < n;y++) {
            for(int x = 0;x < n;x++) {
                for(int z = 0;z < 4;z++) {
                    int dx = dire4[z][0], dy = dire4[z][1];
                    int cx = x, cy = y, c = 0;
                    for(;map[cy][cx] == '1' && 0 <= cx && cx < n && 0 <= cy && cy < n;cx += dx, cy += dy, c++);
                    ans = max(ans, c);
                }
            }
        }
        cout << ans << endl;
    }
}