#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>

int testcase_ends() {
  size_t n;
  scanf("%zu", &n);
  if (n == 0) return 1;

  std::vector<std::string> s(n);
  for (size_t i=0; i<n; ++i) {
    char buf[256];
    scanf("%s", buf);
    s[i] = buf;
  }

  size_t res=0;
  for (size_t i=0; i<n; ++i) {
    res = std::max<size_t>(res, std::count(s[i].begin(), s[i].end(), '1'));
  }

  for (size_t i=0; i<n; ++i) {
    size_t cur=0;
    for (size_t j=0; j<n; ++j)
      if (s[j][i] == '1') ++cur;

    res = std::max(res, cur);
  }

  auto diag=[](const std::vector<std::string> &s)->size_t {
    size_t res=0, n=s.size();
    for (size_t i=0; i<n; ++i) {
      size_t cur=0;
      for (size_t j=0; j<=i; ++j) {
        if (s[j][i-j] == '1') ++cur;
      }

      res = std::max(res, cur);
    }
    return res;
  };
  res = std::max(res, diag(s));

  std::reverse(s.begin(), s.end());
  res = std::max(res, diag(s));

  for (auto &si: s) std::reverse(si.begin(), si.end());
  res = std::max(res, diag(s));

  std::reverse(s.begin(), s.end());
  res = std::max(res, diag(s));

  printf("%zu\n", res);
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}

