#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#include<sstream>
#include<iostream>
using namespace std;
int main(void){

    int n;
    string s[300];
    while(cin>>n,n!=0){
        for(int i = 0;i < n;i++)cin>>s[i];
        int ans = 0;
        // hor
        for(int i = 0;i < n;i++){
            int cnt = 0;
            for(int j = 0;j < n;j++){
                if(s[i][j] == '1')ans = max(ans,++cnt);
                else cnt = 0;
            }
        }

        //ver
        for(int j = 0;j < n;j++){
            int cnt = 0;
            for(int i = 0;i < n;i++){
                if(s[i][j] == '1')ans = max(ans,++cnt);
                else cnt = 0;
            }
        }

        //dia_1
        int dp[300][300] = {};
        for(int i = 0;i < n;i++){
            for(int j = 0;j < n;j++){
                if(s[i][j] == '1'){
                    if(i == 0 || j == 0){
                        dp[i][j] = 1;
                        ans = max(ans,dp[i][j]);
                    }
                    else{
                        dp[i][j] = dp[i-1][j-1] + 1;
                        ans = max(ans,dp[i][j]);
                    }
                }
            }
        }

        //dia_2
        int dp2[300][300] = {};
        for(int i = 0;i < n;i++){
            for(int j = n-1;j >= 0;j--){
                if(s[i][j] == '1'){
                    if(i == 0 || j == n-1){
                        dp2[i][j] = 1;
                        ans = max(ans,dp2[i][j]);
                    }
                    else{
                        dp2[i][j] = dp2[i-1][j+1] + 1;
                        ans = max(ans,dp2[i][j]);
                    }
                }
            }
        }
        cout<<ans<<endl;
    }

    return 0;
}