#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
int n, y, x;
vector<string> table;
int calc(int sy, int sx) 
{
    int res = 0;
    int ny = y, nx = x;
    ny += sy;
    nx += sx;
    while(ny >= 0 and ny < n and nx >= 0 and nx < n)
    {
        if(table[ny][nx] == '0') break;
        res++;
        ny += sy;
        nx += sx;
    }
    return res;
}
int search()
{
    int res = 0;
    res = max(res, calc(1, 0) + calc(-1, 0));
    res = max(res, calc(0, 1) + calc(0, -1));
    res = max(res, calc(-1, 1) + calc(1, -1));
    res = max(res, calc(-1, -1) + calc(1, 1));
    return res + 1;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n, n)
    {
        table.resize(n);
        for(int i = 0; i < n; i++) cin >> table[i];
        int ans = 0;
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < n; j++)
            {
                if(table[i][j] == '0') continue;
                y = i, x = j;
                ans = max(ans, search());
            }
        }
        cout << ans << "\n";
    }
    return 0;
}


