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

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

    vector<string> mass(n);
    for (int i = 0; i < n; ++i)
      cin >> mass[i];

    int ans = 0;
    vector<int> sum(6, 0);
    for (int i = 0; i < n; ++i) {
      // hor, ver
      for (int j = 0; j < n; ++j) {
	sum[0] += mass[i][j] - '0';
	sum[1] += mass[j][i] - '0';
      }
 
      // diag
      for (int j = 0; i+j < n; ++j) {
	sum[2] += mass[i+j][j] - '0';
	sum[3] += mass[n-1-i-j][j] - '0';
	sum[4] += mass[n-1-i-j][n-1-j] - '0';
	sum[5] += mass[i+j][n-1-j] - '0';
      }

      for (unsigned int j = 0; j < sum.size(); ++j) {
	ans = max(ans, sum[j]);
	sum[j] = 0;
      }
    }

    cout << ans << endl;
  }
  return 0;
}