#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 i1 = 1; i1 <= n; ++i1) { for (int i2 = 1; i2 <= n; ++i2) { for (int t = 0; i1 + t <= n&&i2 + t <= n;++t) { int j1 = i1 + t; int j2 = i2 + t; 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; }