// start: 18:46
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cctype>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <sstream>
#include <deque>

#define REP(i, n) for ( int i = 0; i < n; i++ )
#define ENDL <<endl
#define SP <<" "<<
using namespace std;

vector<int> rect(vector<vector<int> > m, int offx, int offy, int w, int h) {
    vector<int> ret(w * h);
    REP(i, h) REP(j, w) {
        ret[w*i+j] = m[offy+i][offx+j];
    }
    return ret;
}

int sum(vector<int> nums) {
    int sum = 0;
    REP(i, nums.size()) {
        sum += nums[i];
    }
    return sum;
}

int main() {
    int n, max_n;
    cin >> n;

    vector<vector<int> > m(n, vector<int>(n));

    REP(y, n) REP(x, n) cin >> m[y][x];

    max_n = m[0][0];

    // 4重ループ
    for ( int h = 1; h <= n; h++ ) {
        for ( int w = 1; w <= n; w++ ) {
            for ( int offy = 0; offy <= n-h; offy++ ) {
                for ( int offx = 0; offx <= n-w; offx++ ) {
                    max_n = max(max_n, sum(rect(m, offx, offy, w, h)));
                }
            }
        }
    }
    cout << max_n ENDL;
    
    return 0;
}