import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

void main(){
    while(true) {
        auto n = readInt();
        if(n == 0) {
            break;
        }
        char[][] m;
        m ~= repeat('0', n+2).array;
        foreach(i; iota(n)) {
            m ~= '0' ~ readln().chomp().to!(char[]) ~ '0';
        }
        m ~= repeat('0', n+2).array;
        auto maxTate = (){
            int ans;
            foreach(i; iota(1, n+2)) {
                foreach(j; iota(1, n+2)) {
                    foreach(k; iota(i, n+2)) {
                        if(m[k][j] != '1') {
                            ans = max(ans, k-i);
                            break;
                        }
                    }
                }
            }
            return ans;
        }();
        auto maxYoko = (){
            int ans;
            foreach(i; iota(1, n+2)) {
                foreach(j; iota(1, n+2)) {
                    foreach(k; iota(j, n+2)) {
                        if(m[i][k] != '1') {
                            ans = max(ans, k-j);
                            break;
                        }
                    }
                }
            }
            return ans;
        }();
        auto maxNaname1 = (){
            int ans;
            foreach(i; iota(1, n+2)) {
                foreach(j; iota(1, n+2)) {
                    foreach(k; iota(min(n+2-i, n+2-j))) {
                        if(m[i+k][j+k] != '1') {
                            ans = max(ans, k);
                            break;
                        }
                    }
                }
            }
            return ans;
        }();
        auto maxNaname2 = (){
            int ans;
            foreach(i; iota(1, n+2)) {
                foreach(j; iota(1, n+2)) {
                    foreach(k; iota(min(n+2-i, j+1))) {
                        if(m[i+k][j-k] != '1') {
                            ans = max(ans, k);
                            break;
                        }
                    }
                }
            }
            return ans;
        }();
        writeln(max(maxTate, maxYoko, maxNaname1, maxNaname2));
    }
}