#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DEBUG 0
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using pii = pair<int, int>; using vi = vector<int>;
static const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
static const int MOD = (int)(1e9 + 7);

int n;
bool isinrange(int x, int y) {
	return x >= 0 && x < n&&y >= 0 && y < n;
}

signed main() {
	for (; cin >> n && n;) {
		vector<string>  a(n);
		rep(i, 0, n)cin >> a[i];

		int ans = 0;
		int di[] = { 0, 1, 1, 1 };
		int dj[] = { 1, 0, 1, -1 };
		rep(i, 0, n)rep(j, 0, n) {
			rep(k, 0, 4) {
				int ii = i, jj = j;
				int cnt = 0;
				while (a[ii][jj] == '1') {
					cnt++;
					ans = max(ans, cnt);
					ii += di[k];
					jj += dj[k];
					if (!isinrange(ii, jj))break;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}