#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<cfloat>

#define f first
#define s second
#define mp make_pair

#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 EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;

int main(){
  int n;
  while(scanf("%d",&n),n){
    char buff[n][n+1];
    REP(i,n) scanf("%s",buff[i]);

    int ans = 0;

    REP(i,n){
      int cnt = 0;
      REP(j,n){
	if(buff[i][j] == '1')
	  cnt++;
	else{
	  ans = max(ans, cnt);
	  cnt = 0;
	}
      }
      ans = max(ans, cnt);
    }

    REP(j,n){
      int cnt = 0;
      REP(i,n){
	if(buff[i][j] == '1')
	  cnt++;
	else{
	  ans = max(ans, cnt);
	  cnt = 0;
	}
      }
      ans = max(ans, cnt);
    }

    REP(i,n){
      int cnt = 0;
      REP(j,n-i){
	if(buff[i+j][j] == '1')
	  cnt++;
	else{
	  ans = max(ans, cnt);
	  cnt = 0;
	}
      }
      ans = max(ans, cnt);
    }

    REP(i,n){
      int cnt = 0;
      REP(j,n-i){
	if(buff[j][i+j] == '1')
	  cnt++;
	else{
	  ans = max(ans, cnt);
	  cnt = 0;
	}
      }
      ans = max(ans, cnt);
    }

    REP(i,n){
      int cnt = 0;
      REP(j,i+1){
	if(buff[j][i-j] == '1')
	  cnt++;
	else{
	  ans = max(ans, cnt);
	  cnt = 0;
	}
      }
      ans = max(ans, cnt);
    }

    REP(i,n){
      int cnt = 0;
      REP(j,i+1){
	if(buff[n-j-1][n-(i-j)-1] == '1')
	  cnt++;
	else{
	  ans = max(ans, cnt);
	  cnt = 0;
	}
      }
      ans = max(ans, cnt);
    }

    printf("%d\n",ans);
  }
  return 0;
}