#include <iostream>
#include <string>
#include <cstring>
#define PI pair<int,int>
using namespace std;
unsigned char m[257][257][4];
int main()
{
  int n,i,j,k,l;
  string s;
  PI p[4] = { PI(0,-1), PI(-1,0), PI(-1,-1), PI(-1,1) };
  for(;;){
    cin >> n;
    if(n==0) break;
    memset(m,0,sizeof(m));
    l = 0;
    for(i=1;i<=n;i++){
      cin >> s;
      for(j=1;j<=n;j++){
	if(s[j-1] == '1'){
	  for(k=0;k<4;k++){
	    m[i][j][k] = m[i+p[k].first][j+p[k].second][k]+1;
	    if(l<m[i][j][k]) l = m[i][j][k];
	  }
	}
      }
    }
    cout << l << endl;
  }
  return 0;
}