#include <iostream>
#include <string>
using namespace std;


class Cell{
public:
  int d, r, rd, ld;
  Cell(int d = 0, int r = 0, int rd = 0, int ld = 0)
    : d(d), r(r), rd(rd), ld(ld) {}
  int max() {
    if(d >= r && d >= rd && d >= ld) return d;
    if(r >= d && r >= rd && r >= ld) return r;
    if(rd >= d && rd >= r && rd >= ld) return rd;
    if(ld >= d && ld >= r && ld >= rd) return ld;
  }
};

int main() {
  while(1) {
    int n;
    cin >> n;
    if(n == 0) break;

    string data[n+1];

    data[0] = "";
    for(int i = 0; i < n+2; i++) {
      data[0] += "0";
    }
    for(int i = 1; i < n+1; i++) {
      string str;
      cin >> str;
      data[i] = "0" + str + "0";
    }

    Cell c[n+1][n+1];
    for(int i = 1; i < n+1; i++) {
      for(int j = 1; j < n+1; j++) {
	if(data[i][j] == '1') {
	  c[i][j].d = c[i-1][j].d + 1;
	  c[i][j].r = c[i][j-1].r + 1;
	  c[i][j].rd = c[i-1][j-1].rd + 1;
	  c[i][j].ld = c[i-1][j+1].ld + 1;
	} else if(data[i][j] == '0') {
	  c[i][j].d = c[i][j].r = c[i][j].rd = c[i][j].ld = 0;
	}
      }
    }

    int max = -1;
    for(int i = 1; i < n+1; i++) {
      for(int j = 1; j < n+1; j++) {
	if(c[i][j].max() > max) max = c[i][j].max();
      }
    }
    cout << max << endl;
  }
  return 0;
}