#include int a[55][55],l[55][55],c[55][55]; int main() { int n; scanf("%d", &n); for (int i = 1; i <= n;++i) for (int j = 1; j <= n; ++j) { scanf("%d", &a[i][j]); } int minim = -5000; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { l[i][j] = l[i][j - 1] + a[i][j]; c[i][j] = c[i - 1][j] + a[i][j]; } } for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { for (int t = j; t <= n; ++t) { if (minim < l[i][t] - l[i][j - 1]) minim = l[i][t] - l[i][j - 1]; if (minim < c[t][i]-c[j-1][i]) minim = c[t][i] - c[j - 1][i]; } } } for (int i1 = 1; i1 <= n; ++i1) { for (int i2 = 1; i2 <= n; ++i2) { for (int j1 = i1+1; j1 <= n; ++j1) { for (int j2 = i2+1; j2 <= n; ++j2) { if (l[i1][j2]-l[i1][i2-1]+l[j1][j2]-l[j1][i2-1]+c[j1][i2]-c[i1-1][i2]+c[j1][j2]-c[i1-1][j2]-a[i1][i2]-a[j1][j2]-a[i1][j2]-a[j1][i2]>minim) { minim = l[i1][j2] - l[i1][i2 - 1] + l[j1][j2] - l[j1][i2 - 1] + c[j1][i2] - c[i1 - 1][i2] + c[j1][j2] - c[i1 - 1][j2] - a[i1][i2] - a[j1][j2] - a[i1][j2] - a[j1][i2]; } } } } } printf("%d", minim); scanf("%d", &minim); return 0; }