#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
#define INF 100000000
#define MAXN 110
typedef long long ll;

int n;
int a[MAXN][MAXN], dp[MAXN][MAXN];

int main(void) {
    cin >> n;
    for (int i = 0; i < n; i++) 
        for (int j = 0; j < n; j++)
            cin >> a[i][j];
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1] + a[i-1][j-1];
        }
    }
//    for (int i = 1; i <= n; i++) {
//        for (int j = 1; j <= n; j++) {
//            cout << dp[i][j] << " ";
//        }
//        cout << endl;
//    }
    int ret = -INF;
    for (int i = 1; i <= n; i++) {
        for (int j = i; j <= n; j++) {
            for (int k = 1; k <= n; k++) {
                for (int l = k; l <= n; l++) {
                    int num = dp[j][l] - dp[i-1][l] - dp[j][k-1] + dp[i-1][k-1];
                    ret = max(ret, num);
                }
            }
        }
    }
    cout << ret << endl;
    return 0;
}