#include #include #include #include #include #include using namespace std; int n, a[55][55], sol, sol1; int main() { //freopen("input.txt", "r", stdin); //__TEST_MODE__ freopen("output.txt", "w", stdout); cin >> n; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) cin >> a[i][j]; sol = a[1][1]; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) for (int k = 1; (i + k - 1) <= n && (j + k - 1) <= n; k++) { sol1 = 0; if (k == 1) { sol1 = a[i][j]; } else { for (int l = 0; l < k; l++) sol1 += a[i][j+l] + a[i+k-1][j+l] + a[i+l][j] + a[i+l][j+k-1]; sol1 += - a[i][j] - a[i+k-1][j] - a[i][j+k-1] - a[i+k-1][j+k-1]; } sol = max(sol, sol1); } cout << sol; return 0; }