#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, max = 0;
  cin >> n;
  n = n + 4;
  int** A = new int*[n];
  for (int i = 0; i < n; i++) A[i] = new int[n];
  for (int i = 0; i < n; i++) {
    A[i][0] = 0;
    A[i][1] = 0;
    A[i][n - 1] = 0;
    A[i][n - 2] = 0;
  }
  for (int j = 0; j < n; j++) {
    A[0][j] = 0;
    A[1][j] = 0;
    A[n - 2][j] = 0;
    A[n - 1][j] = 0;
  }
  for (int i = 2; i < n - 2; i++)
    for (int j = 2; j < n - 2; j++) cin >> A[i][j];
  for (int i = 2; i < n - 2; i++)
    for (int j = 2; j < n - 2; j++) {
      if (A[i][j] + A[i][j - 1] + A[i][j - 2] > max)
        max = A[i][j] + A[i][j - 1] + A[i][j - 2];
      if (A[i][j] + A[i][j - 1] + A[i + 1][j - 1] > max)
        max = A[i][j] + A[i][j - 1] + A[i + 1][j - 1];
      if (A[i][j] + A[i][j - 1] + A[i - 1][j - 1] > max)
        max = A[i][j] + A[i][j - 1] + A[i - 1][j - 1];
      if (A[i][j] + A[i - 1][j] + A[i - 1][j - 1] > max)
        max = A[i][j] + A[i - 1][j] + A[i - 1][j - 1];
      if (A[i][j] + A[i - 1][j] + A[i - 2][j] > max)
        max = A[i][j] + A[i - 1][j] + A[i - 2][j];
      if (A[i][j] + A[i - 1][j] + A[i - 1][j + 1] > max)
        max = A[i][j] + A[i - 1][j] + A[i - 1][j + 1];
      if (A[i][j] + A[i][j + 1] + A[i - 1][j + 1] > max)
        max = A[i][j] + A[i][j + 1] + A[i - 1][j + 1];
      if (A[i][j] + A[i][j + 1] + A[i][j + 2] > max)
        max = A[i][j] + A[i][j + 1] + A[i][j + 2] > max;
      if (A[i][j] + A[i][j + 1] + A[i + 1][j + 1] > max)
        max = A[i][j] + A[i][j + 1] + A[i + 1][j + 1];
      if (A[i][j] + A[i + 1][j] + A[i + 1][j + 1] > max)
        max = A[i][j] + A[i + 1][j] + A[i + 1][j + 1];
      if (A[i][j] + A[i + 1][j] + A[i + 2][j] > max)
        max = A[i][j] + A[i + 1][j] + A[i + 2][j];
      if (A[i][j] + A[i + 1][j] + A[i + 1][j - 1] > max)
        max = A[i][j] + A[i + 1][j] + A[i + 1][j - 1];
    }
  for (int i = 0; i < n; i++) delete[] A[i];
  delete A;
  cout << int(sqrt(max));
  return 0;
}
