#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    while (cin>>n) {
        if (n==0) {
            break;
        } else {
            char a;
            std::vector<vector<char>> vec(n,vector<char>(n));
            for (int i=0;i<n;i++) {
                for (int j=0;j<n;j++) {
                    cin>>a;
                    vec.at(i).at(j)=a;
                }
            }
            int countVer=0,countSide=0,countDiaLeft=0,countDiaRight=0,maxCount=0;
            for (int l=0;l<n;l++) {
                for (int m=0;m<n;m++) {
                    if (vec.at(l).at(m)=='1') {
                        int tmp1=l;
                        int tmp2=m;
                        //横探索
                        while (tmp2!=n&&vec.at(tmp1).at(tmp2)=='1') {
                            countSide++;
                            tmp2++;
                        }
                        tmp1=l;
                        tmp2=m;
                        //縦探索
                        while (tmp1!=n&&vec.at(tmp1).at(tmp2)=='1') {
                        countVer++;
                        tmp1++;
                        }
                        tmp1=l;
                        tmp2=m;
                        //左斜め探索
                        while (tmp1!=n&&tmp2!=-1&&vec.at(tmp1).at(tmp2)=='1') {
                            countDiaLeft++;
                            tmp1++;
                            tmp2--;
                        }
                        //右斜め探索
                        tmp1=l;
                        tmp2=m;
                        while (tmp1!=n&&tmp2!=n&&vec.at(tmp1).at(tmp2)=='1') {
                            countDiaRight++;
                            tmp1++;
                            tmp2++;
                        }
                        int ans=max(countVer,max(countSide,max(countDiaLeft,countDiaRight)));
                        if (ans>maxCount) {
                            maxCount=ans;
                        }
                        countVer=0,countSide=0,countDiaLeft=0,countDiaRight=0;
                    }
                }
            }
            cout<<maxCount<<endl;
        }
    }
}
