#include using namespace std; int a[52][52]; int main(){ freopen("MaxSquare.in","r",stdin); freopen("MaxSquare.out","w",stdout); int smax=0,n,i,j,i1,i2,s=0; scanf("%d",&n); for(i=1;i<=n;i++) for(j=1;j<=n;j++) scanf("%d",&a[i][j]); for(i=1;i<=n;i++){ for(j=1;j<=n;j++){ for(i1=1;i1<=n-j+1;i1++){ for(i2=0;i2<=i+i1-1;i2++){ s=s+a[i][j+i2]; s=s+a[i+i1-1][j+i2]; s=s+a[i+i2][j]; s=s+a[i+i2][j+i1-1]; } s=s-a[i][j]; s=s-a[i][j+i1-1]; s=s-a[i+i1-1][j]; s=s-a[i+i1-1][j+i1-1]; if(s>smax) smax=s; s=0; } } } printf("%d",smax); return 0; }