#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    vector< vector<int> > v(n);
    rep(i,n) {
        v[i].resize(n);

        rep(j,n) cin >> v[i][j];
    }

    rep(i,n) {
        REP(j,1,n) {
            v[i][j] += v[i][j-1];
        }
    }

    REP(i,1,n) {
        rep(j,n) {
            v[i][j] += v[i-1][j];
        }
    }

    int ans = -INF;
    rep(i,n) {
        rep(j,n) {
            rep(k,i+1) {
                rep(l,j+1) {
                    int ret;
                    if(k > 0 && l > 0) {
                        ret = v[i][j] - v[k-1][j] - v[i][l-1] + v[k-1][l-1];
                    } else if(k > 0) {
                        ret = v[i][j] - v[k-1][j];
                    } else if(l > 0) {
                        ret = v[i][j] - v[i][l-1];
                    } else {
                        ret = v[i][j];
                    }

                    ans = max(ans,ret);
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}