#include <bits/stdc++.h>

using namespace std;

int main(void) {
    int n, a, dp[110][110] = {};
    cin >> n;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++) {
            cin >> a;
            dp[i][j] = a + dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1];
        }
    
    int ans = -1e9;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            for (int k = i + 1; k <= n; k++)
                for (int l = j + 1; l <= n; l++)
                    ans = max(ans, dp[k][l] - dp[k][j] - dp[i][l] + dp[i][j]);
    
    cout << ans << endl;

    return 0;
}
