#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
using namespace std;

#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()

int main() {
  int n;
  while(cin >> n, n) {
    char ba[n][n];
    REP(i,n)
      REP(j,n)
      cin >> ba[j][i];
    int dp[n][n][4]; // ツ可。ツ、ツ縦ツ、ツ偲篠湘」ツ債カツ、ツ偲篠湘」ツ右
    memset(dp,0,sizeof(dp));
    
    REP(y,n) {
      REP(x,n) {
        if (ba[x][y] == '1') {
          dp[x][y][0] = ((x>0)?dp[x-1][y][0]:0) + 1;
          dp[x][y][1] = ((y>0)?dp[x][y-1][1]:0) + 1;
          dp[x][y][2] = ((x>0&&y>0)?dp[x-1][y-1][2]:0) + 1;
          dp[x][y][3] = ((x<n-1&&y>0)?dp[x+1][y-1][3]:0) + 1;
        }
      }
    }
    cout << *max_element(&dp[0][0][0],&dp[n-1][n-1][3]) << endl;
  }
}