#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;

int main(){
    int n; cin >> n;
    vvi G(n, vi(n));
    rep(i, n)rep(j, n) cin >> G[i][j];

    vvi dp(n + 1, vi(n + 1));
    rep(i, n)rep(j, n){
        dp[i + 1][j + 1] = G[i][j] + dp[i + 1][j] + dp[i][j + 1] - dp[i][j];
    }

    int ans = -(1LL << 31);
    loop(i1, 1, n + 1)loop(i2, 0, n)loop(j1, 1, n + 1)loop(j2, 0, n){
        int t = dp[i1][j1] - dp[i1][j2] - dp[i2][j1] + dp[i2][j2];
        ans = max(t, ans);
    }
    cout << ans << endl;
}