#include #define NMAX 55 using namespace std; int A[NMAX][NMAX],N,MAX=0; void read() { scanf("%d\n",&N); for (int i=1;i<=N;i++) for (int j=1;j<=N;j++) scanf("%d ",&A[i][j]); } int calc(int x1,int y1,int x2,int y2) { int sum=0; for (int i=x1;i<=x2;i++) sum=sum+A[i][y1]+A[i][y2]; for (int j=y1;j<=y2;j++) sum=sum+A[x1][j]+A[x2][j]; sum=sum-A[x1][y1]-A[x2][y1]-A[x2][y2]-A[x1][y2]; return sum; } void solve() { int i,j,k,l; for (int i=1;i<=N;i++) for (int j=1;j<=N;j++) for (int k=i;k<=N;k++) for (int l=j;l<=N;l++) if (calc(i,j,k,l)>MAX && (k-i)==(l-j)) MAX=calc(i,j,k,l); printf("%d\n",MAX); } int main() { // freopen ("in.txt","r",stdin); // freopen ("out.txt","w",stdout); read(); if (N==1) printf("%d\n",A[1][1]); else solve(); fclose(stdin); fclose(stdout); return 0; }