#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;


int main(){
	int n;
	while(cin>>n,n){
		vector<string> v(n);
		FOR(i,n) cin>>v[i];
		FOR(i,n) FOR(j,n) v[i][j] -= '0';
		int ans = 0;
		FOR(i,n){
			int a = 0;
			FOR(j,n) a += v[i][j];
			ans = max(ans,a);
			a = 0;
			FOR(j,n) a += v[j][i];
			ans = max(ans,a);
		}

		int m = n-1;
		FOR(i,n){
			int a = 0,b = 0,c = 0,d = 0;
			FOR(j,i+1){
				a += v[i-j][j];
				c += v[m-(i-j)][j];
				b += v[m-(i-j)][m-j];
				d += v[i-j][m-j];
			}
			ans = max(ans,max(max(a,b),max(c,d)));
		}

		cout << ans << endl;
	}
	
	
	return 0;
}