#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int n;
  while(cin >> n) {
    if(!n) return 0;
    string g[n] = {};

    rep(i, 0, n) {
      cin >> g[i];
    }
    int ma = 0;

    rep(i, 0, n) {
      int rs = 0;
      int s = 0, ss = 0;
      rep(j, 0, n) {
        if(g[i][j] == '1') rs++;
        else {
          s = max(s, rs);
          rs = 0;
        }
        if(j == n - 1) s = max(s, rs);
      }
      rs = 0;
      rep(j, 0, n) {
        if(g[j][i] == '1') rs++;
        else {
          ss = max(ss, rs);
          rs = 0;
        }
        if(j == n - 1) ss = max(ss, rs);
      }
      ma = max(ma, max(s, ss));
    }

    rep(i, 0, n) {
      int x = i, y = 0;
      int s = 0, ss = 0;
      int rs = 0;
      while(1) {
        if(g[x][y] == '1') rs++;
        else {
          s = max(s, rs);
          rs = 0;
        }
        x += 1, y += 1;
        if(x == n || y == n) {
          s = max(s, rs);
          rs = 0;
          break;
        }
      }
      x = i, y = 0;
      while(1) {
        if(g[x][y] == '1') rs++;
        else {
          ss = max(ss, rs);
          rs = 0;
        }
        x -= 1, y += 1;
        if(x == -1 || y == n) {
          ss = max(ss, rs);
          rs = 0;
          break;
        }
      }
      ma = max(ma, max(s, ss));
    }


    rep(i, 0, n) {
      int x = i, y = n - 1;
      int s = 0, ss = 0;
      int rs = 0;
      
      while(1) {
        if(g[x][y] == '1') rs++;
        else {
          s = max(s, rs);
          rs = 0;
        }
        x += 1, y -= 1;
        if(x == n || y == -1) {
          s = max(s, rs);
          rs = 0;
          break;
        }
      }
      x = i, y = n - 1;
      while(1) {
        if(g[x][y] == '1') rs++;
        else {
          ss = max(ss, rs);
          rs = 0;
        }
        x -= 1, y -= 1;
        if(x == -1 || y == -1) {
          ss = max(ss, rs);
          rs = 0;
          break;
        }
      }
      ma = max(ma, max(s, ss));
    }


    rep(i, 0, n) {
      int x = 0, y = i;
      int s = 0, ss = 0;
      int rs = 0;

      while(1) {
        if(g[x][y] == '1') rs++;
        else {
          s = max(s, rs);
          rs = 0;
        }
        x += 1, y += 1;
        if(x == n || y == n) {
          s = max(s, rs);
          rs = 0;
          break;
        }
      }
      x = 0, y = i;
      while(1) {
        if(g[x][y] == '1') rs++;
        else {
          s = max(s, rs);
          rs = 0;
        }
        x += 1, y -= 1;
        if(x == n || y == -1) {
          s = max(s, rs);
          rs = 0;
          break;
        }
      }
      ma = max(ma, max(s, ss));
    }


    rep(i, 0, n) {
      int x = n - 1, y = i;
      int s = 0, ss = 0;
      int rs = 0;
      while(1) {
        if(g[x][y] == '1') rs++;
        else {
          s = max(s, rs);
          rs = 0;
        }
        x -= 1, y += 1;
        if(x == -1 || y == n) {
          s = max(s, rs);
          rs = 0;
          break;
        }
      }
      x = n - 1, y = i;
      while(1) {
        if(g[x][y] == '1') rs++;
        else {
          s = max(s, rs);
          rs = 0;
        }
        x -= 1, y -= 1;
        if(x == 0 || y == 0) {
          s = max(s, rs);
          rs = 0;
          break;
        }
      }
      ma = max(ma, max(s, ss));
    }

    cout << ma << endl;
  }
}

Measured memory_bytes: 3224