#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

int main(){
    int n;
    cin >> n;
    vector<vector<int>> sum(n + 1, vector<int>(n + 1, 0));
    REP(i, n){
        int sum_tmp = 0;
        REP(j, n){
            int tmp;
            cin >> tmp;
            sum_tmp += tmp;
            sum[i + 1][j + 1] = sum[i][j + 1] + sum_tmp;
        }
    }
    int ans = -inf;
    REP(i, n + 1) REP(j, n + 1) REP(k, i) REP(l, j){
        int tmp = sum[i][j] - sum[i][l] - sum[k][j] + sum[k][l];
        // cout << tmp << endl;
        if(ans < tmp) ans = tmp;
    }
    cout << ans << endl;
}
