Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
	"strings"
	"sort"
)

var scanner= bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}
		mp := make([]string, n)
		for i := range mp {
			scanner.Scan()
			mp[i] = "0" + scanner.Text() + "0"
		}
		tmp := make([]string, n+2)
		for i := range tmp {
			tmp[i] = "0"
		}
		mp = append([]string{strings.Join(tmp, "")}, mp...)
		mp = append(mp, strings.Join(tmp, ""))
		score := make([][][]int, n+2)
		for i := range score {
			score[i] = make([][]int, n+2)
			for j := range score[i] {
				score[i][j] = make([]int, 4)
			}
		}
		max_score := 0
		for i := 1; i < n+1; i++ {
			for j := 1; j < n+1; j++ {
				tmps := mp[i]
				if string(tmps[j]) == "1" {
					score[i][j][0] = score[i - 1][j][0] + 1
					score[i][j][1] = score[i][j - 1][1] + 1
					score[i][j][2] = score[i - 1][j - 1][2] + 1
					score[i][j][3] = score[i - 1][j + 1][3] + 1
					max_score = max(max_score, score[i][j][0], score[i][j][1], score[i][j][2], score[i][j][3])
				}
			}
		}
		fmt.Println(max_score)
	}
}

func max(a, b, c, d, e int) int {
	buf := []int{a, b, c, d, e}
	sort.Ints(buf)
	return buf[len(buf)-1]
}

C++: // 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1, 1, 1};
int dy[] = {1, -1, 0, 0, 1, -1};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int N, board[300][300];
 
int solve(int row, int col) {
    int res = 0;
    for(int k=0; k<6; k++) {
        int x = row, y = col, cons = 0;
        while(x >= 0 and x < N and y >= 0 and y < N) {
            if(board[x][y] > 0) cons++;
            else chmax(res, cons), cons = 0;
            x += dx[k], y += dy[k];
        }
        chmax(res, cons);
    }
    return res;
}

signed main() {
    while(cin >> N, N) {
        for(int i=0; i<N; i++) {
            for(int j=0; j<N; j++) {
                char c; cin >> c;
                board[i][j] = c - '0';
            }
        }

        int ans = 0;
        for(int i=0; i<N; i++) {
            chmax(ans, solve(i, 0));
            chmax(ans, solve(0, i));
            chmax(ans, solve(N-1, i));
            chmax(ans, solve(i, N-1));
        }
        cout << ans << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
 
using namespace std;
 
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-3;
const double PI = acos(-1);

int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};

string s[300];
int n;
int tate[300][300], yoko[300][300], naname1[300][300], naname2[300][300];

int main(){
	while(cin>>n && n){
		rep(i, n) cin>>s[i];
		int ans = 0;
		rep(i, 300) rep(j, 300) tate[i][j] = yoko[i][j] = naname1[i][j] = naname2[i][j] = 0;
		rep(i, n){
			rep(j, n){
				tate[i+1][j+1] = (s[i][j]=='1'?tate[i][j+1]+1:0);
				yoko[i+1][j+1] = (s[i][j]=='1'?yoko[i+1][j]+1:0);
				naname1[i+1][j+1] = (s[i][j]=='1'?naname1[i][j]+1:0);
				ans = max({ans, tate[i+1][j+1], yoko[i+1][j+1], naname1[i+1][j+1]});
			}
		}
		for(int i = n; i > 0; i--){
			for(int j = 1; j <= n; j++){
				naname2[i][j] = (s[i-1][j-1]=='1'?naname2[i+1][j-1]+1:0);
				ans = max(ans, naname2[i][j]);
			}
		}
		cout<<ans<<endl;
	}
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int n;
char grid[256][256];

int solve(){
  int res = 0, c;
  rep(i, n){
    c = 0;
    rep(j, n){
      if(grid[i][j] == '1') res = max(res, ++c);
      else c = 0;
    }
  }

  rep(j, n){
    c = 0;
    rep(i, n){
      if(grid[i][j] == '1') res = max(res, ++c);
      else c = 0;
    }
  }

  rep(i, n){
    c = 0;
    rep(j, n){
      if(i - j < 0) break;
      if(grid[j][i-j] == '1') res = max(res, ++c);
      else c = 0;
    }
  }

  rep(i, n){
    c = 0;
    rep(j, n){
      if(n-j < 0 || n-i+j-1 >= n || n-i+j-1 < 0) break;
      if(grid[n-i+j-1][n-j] == '1') res = max(res, ++c);
      else c = 0;
    }
  }

  rep(i, n){
    c = 0;
    rep(j, n){
      if(n - i + j - 1>= n) break;
      if(grid[j][n-i+j-1] == '1') res = max(res, ++c);
      else c = 0;
    }
  }

  rep(i, n){
    c = 0;
    rep(j, n){
      if(i + j >= n) break;
      if(grid[i+j][j] == '1') res = max(res, ++c);
      else c = 0;
    }
  }

  return res;
}

int main(){
  while(scanf("%d", &n) && n){
    memset(grid, 0, sizeof(grid));
    rep(i, n) scanf("%s", grid[i]);
    printf("%d\n", solve());
  }
  return 0;
}