#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
int maxl(vector<int> seq){
  FOR(i,1,seq.size()) seq[i] += (seq[i])?seq[i-1]:0;
  int ret = 0;
  REP(i,seq.size()) ret = max(ret,seq[i]);
  return ret;
}
int main(void){
  int n;
  while(cin>>n){
    if(n==0) break;
    vector<string> grid(n);
    int ans = 0;
    REP(i,n) cin>>grid[i];
    REP(i,n){
      vector<int> seq;
      REP(j,n)seq.push_back(grid[i][j]-'0');
      ans = max(ans,maxl(seq));
    }
    REP(i,n){
      vector<int> seq;
      REP(j,n)seq.push_back(grid[j][i]-'0');
      ans = max(ans,maxl(seq));
    }
    REP(i,n){
      int x=i,y=0;
      vector<int> seq,seq2,seq3,seq4;
      REP(j,i+1)seq.push_back(grid[x--][y++]-'0'); 
      ans = max(ans,maxl(seq));
      x = n-1; y = n-1-i;
      REP(j,i+1)seq2.push_back(grid[x--][y++]-'0');
      ans = max(ans,maxl(seq2));
      x = n-1-i; y=0;
      REP(j,i+1)seq3.push_back(grid[x++][y++]-'0');
      ans = max(ans,maxl(seq3));
      x = i; y=n-1;
      REP(j,i+1)seq4.push_back(grid[x--][y--]-'0');
      ans = max(ans,maxl(seq4));
    }
    cout<<ans<<endl;
  }

  return 0;
}