import std.stdio;
import std.string;
import std.algorithm;

string[255] s;
int[4] tmp;

void main(){
	int n, ans;
	while (readf("%d\n", &n), n) {
		ans = 0;
		foreach (i; 0..n) s[i] = chomp(readln());

		foreach (y; 0..n) {
			tmp[] = 0;
			foreach (x; 0..n) {
				if (s[y][x] == '1') tmp[0]++;
				if (s[x][y] == '1') tmp[1]++;
			}
			ans = max(ans, tmp[0]);
			ans = max(ans, tmp[1]);
		}

		foreach (i; 0..n) {
			tmp[] = 0;
			foreach (j; i..n) {
				if (s[j-i][0+j] == '1') tmp[0]++;
				if (s[0+j][j-i] == '1') tmp[1]++;
				if (s[(n-1)-(j-i)][0+j] == '1') tmp[2]++;
				if (s[(n-1)-(0+j)][j-i] == '1') tmp[3]++;
			}
			ans = max(ans, tmp[0]);
			ans = max(ans, tmp[1]);
			ans = max(ans, tmp[2]);
			ans = max(ans, tmp[3]);
		}
		writeln(ans);
	}
}