#include using namespace std; int v[60][60], v2[60][60], v3[60][60]; int calcSum(int i, int j, int i2, int j2) { int sum = 0; //if (i2-i != j2-j) return -5000000; sum = v2[i2][j2] - v2[i][j2]; if (j!=j2) sum += v2[i2][j] - v2[i][j]; sum += v3[i2][j2] - v3[i2][j]; if (i!=i2) sum += v3[i][j2] - v3[i][j]; sum += v[i][j]; if (i != i2 && j != j2) sum -= v[i2][j2]; return sum; } int main() { int n,nr,r=-5000000,i,j,i2,j2; cin>>n; for (i=1;i<=n;i++) for (j=1;j<=n;j++) { cin>>v[i][j]; if (i!=1) { v2[i][j] = v2[i-1][j]; } v2[i][j] += v[i][j]; if (j!=1) { v3[i][j] = v3[i][j-1]; } v3[i][j] += v[i][j]; } for (i=1;i<=n;i++) for (j=1;j<=n;j++) for (i2=i;i2<=n;i2++) for (j2=j;j2<=n;j2++) { nr = calcSum(i,j,i2,j2); if (nr > r) r = nr; } cout<