#include <fstream>
#include <iostream>
#include <vector>
#include <bitset>
#include <string.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <deque>

using namespace std;

const char infile[] = "maxsquare.in";
const char outfile[] = "output.out";

ifstream fin(infile);
ofstream fout(outfile);

const int MAXN = 55;
const int oo = 0x3f3f3f3f;

typedef vector<int> Graph[MAXN];
typedef vector<int> :: iterator It;

const inline int min(const int &a, const int &b) { if( a > b ) return b;   return a; }
const inline int max(const int &a, const int &b) { if( a < b ) return b;   return a; }
const inline void Get_min(int &a, const int b)    { if( a > b ) a = b; }
const inline void Get_max(int &a, const int b)    { if( a < b ) a = b; }

int N, a[MAXN][MAXN], ans = -oo;

inline int getSum(int x1, int y1, int x2, int y2) {
    int Ans = 0;
    for(int i = x1 ; i <= x2 ; ++ i) {
        Ans += a[i][y1];
        Ans += a[i][y2];
    }
    for(int j = y1 ; j <= y2 ; ++ j) {
        Ans += a[x1][j];
        Ans += a[x2][j];
    }
    Ans -= a[x1][y1];
    Ans -= a[x1][y2];
    Ans -= a[x2][y1];
    Ans -= a[x2][y2];
    //cout << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << ' ' << Ans << '\n';
    return Ans;
}

int main() {
    cin >> N;
    for(int i = 1 ; i <= N ; ++ i)
        for(int j = 1 ; j <= N ; ++ j) {
            cin >> a[i][j];
            ans = max(ans, a[i][j]);
        }
    for(int len = 2 ; len <= N ; ++ len) {
        for(int i = 1 ; i + len - 1 <= N ; ++ i)
            for(int j = 1 ; j + len - 1 <= N ; ++ j) {
                int x1 = i, y1 = j, x2 = i + len - 1, y2 = j + len - 1;
                ans = max(ans, getSum(x1, y1, x2, y2));
            }
    }
    cout << ans << '\n';
    fin.close();
    fout.close();
    return 0;
}