#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#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 <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second


int dx[]={0,1,0,-1},dy[]={1,0,-1,0};

main(){
  int n;
  while(cin>>n,n){
    int grid[n][n],tate[n][n],yoko[n][n],lurd[n][n],ruld[n][n];
    char c;
    rep(i,n)rep(j,n){
      cin>>c;
      tate[i][j]=yoko[i][j]=lurd[i][j]=ruld[i][j]=grid[i][j]=c-'0';
    }
    

    int ans=0;
    rep(i,n){
      rep(j,n){
	if(grid[i][j]==0)continue;
	if(i&&j+1<n&&ruld[i-1][j+1])ruld[i][j]=max(ruld[i][j],ruld[i-1][j+1]+1);
	if(i&&tate[i-1][j])tate[i][j]=max(tate[i][j],tate[i-1][j]+1);
	if(i&&j&&lurd[i-1][j-1])lurd[i][j]=max(lurd[i][j],lurd[i-1][j-1]+1);
	if(j&&yoko[i][j-1])yoko[i][j]=max(yoko[i][j],yoko[i][j-1]+1);
	ans=max(ans,max(tate[i][j],max(yoko[i][j],max(lurd[i][j],ruld[i][j]))));
      }
    }
    rep(i,n){
      rep(j,n){
	//	printf("%2d",grid[i][j]);
      }
      //      cout<<endl;
    }
    cout<<ans<<endl;
  }
}