#include using namespace std; int s1[55][55],s2[55][55],m[55][55]; int main() { int n,i,j,x,smax=-19600,sum,k; scanf("%d",&n); for(i=1; i<=n; ++i) for(j=1; j<=n; ++j) { scanf("%d",&m[i][j]); s1[i][j]=s1[i][j-1]+m[i][j]; s2[i][j]=s2[i-1][j]+m[i][j]; } for(k=1; k<=n; ++k) for(i=1; i<=n-k+1; ++i) for(j=1; j<=n-k+1; ++j) { if (k>=2) { sum=0; sum+=s1[i][j+k-1]-s1[i][j-1]; sum+=s1[i+k-1][j+k-1]-s1[i+k-1][j-1]; sum+=s2[i+k-1][j]-s2[i-1][j]; sum+=s2[i+k-1][j+k-1]-s2[i-1][j+k-1]; sum-=m[i][j]+m[i+k-1][j]+m[i][j+k-1]+m[i+k-1][j+k-1]; if (sum>smax) smax=sum; } else if (k==1) { if (m[i][j]>smax) smax=m[i][j]; } } printf("%d\n",smax); return 0; }