#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
const int INF = 1e8;
using namespace std;

template <class T> class CumulativeSum2D {
    public:
        vector<vector<T>> s;
        int h, w;
        CumulativeSum2D(const vector<vector<T>> &a) {
            h = a.size();
            w = a[0].size();
            s = vector<vector<T>>(h + 1, vector<T>(w + 1, 0));
            rep(i, h) rep(j, w) s[i + 1][j + 1] = a[i][j];
            rep(i, h + 1) rep(j, w) s[i][j + 1] += s[i][j];
            rep(i, h) rep(j, w + 1) s[i + 1][j] += s[i][j];
        }

        int sum(int i, int j, int h, int w) {
            return s[i + h][j + w] - s[i][j + w] + s[i][j] - s[i + h][j];
        }

        int maximumSubMatrix(){
            int ret = -INF;
            rep(i,h + 1) rep(j,w + 1) range(k,1,h - i + 1) range(l,1,w - j + 1){
                ret = max(ret, sum(i,j,k,l));
            }
            return ret;
        }
};

int main(){
    int n;
    cin >> n;

    vector<vector<int>> v(n, vector<int>(n));
    rep(i,n) rep(j,n) cin >> v[i][j];

    CumulativeSum2D<int> cumsum(v);
    cout << cumsum.maximumSubMatrix() << endl;
}