#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 s = 0, ss = 0;
      rep(j, 0, n) if(g[i][j] == '1') s++;
      rep(j, 0, n) if(g[j][i] == '1') ss++;
      ma = max(ma, max(s, ss));
    }

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


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


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


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

    cout << ma << endl;
  }
}