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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    auto mat = make_v(n, n, 0);
    REP(i, 0, n) {
        REP(j, 0, n) {
            cin >> mat[i][j];
        }
    }
    auto acc = make_v(n, n + 1, 0LL);
    REP(i, 0, n) {
        REP(j, 0, n) {
            acc[i][j + 1] += acc[i][j] + mat[i][j];
        }
    }
    ll ans = -(1LL << 60);
    REP(i, 0, n + 1) {
        REP(j, i + 1, n + 1) {
            ll t = 0;
            REP(k, 0, n) {
                if (t >= 0) {
                    t += acc[k][j] - acc[k][i];
                } else {
                    t = acc[k][j] - acc[k][i];
                }
                ans = max(ans, t);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

