#include<stdio.h>int main(){ int n; int sum=0; int s=0; int a[100][100]; scanf("%d",&n); for(int i=0;i<n;i++) { for( int j=0;j<n;j++) { scanf("%d",&a[i][j]); // getting the input into a n*n arrar sum+=a[i][j]; // i am making the sum(final sum variable) initialised to the sum of all the input } }//-------------------------------------------------------- for(int p=0;p<n;p++) // for each element in the 2d arrar making that element as { // left top corner of the rect for( int q=0;q<n;q++) { int r=n; int c=n; while(r!=0) { for(int i=p;i<r;i++) { for(int j=q;j<c;j++) { s+=a[i][j]; } } r--; if(s>sum) sum=s; //if the sum of the now calculated.. rect is greater than sum assin sum=s s=0; } r=n; c=n; while(c!=0) { for(int i=p;i<r;i++) { for(int j=q;j<c;j++) { s+=a[i][j]; } } c--; if(s>sum) sum=s; s=0; } } }//---------------------------- printf("%d",sum); return 0;}