//# include # include # define dim 105 using namespace std; // ifstream f("square.in"); // ofstream g("square.out"); int a[ dim ][ dim ], lin[ dim ][ dim ], col[ dim ][ dim ]; int n; int sol = -999999999; void citire() { int i, j; cin >> n; for ( i = 1 ; i <= n ; i++ ) for ( j = 1 ; j <= n ; j++ ) { cin >> a[ i ][ j ]; lin[ i ][ j ] = a[ i ][ j ] + lin[ i ][ j - 1 ]; col[ i ][ j ] = a[ i ][ j ] + col[ i - 1 ][ j ]; } /* for ( i = 1 ; i <= n ; i++ ) { for ( j = 1 ; j <= n ; j++ ) g << col[ i ][ j ] << " "; g << "\n"; } */ } void rezolvare() { int i, j, x, y; for ( i = 1 ; i <= n ; i++ ) for ( j = 1 ; j <= n ; j++ ) { x = i; y = j; sol = max( sol, lin[ i ][ y ] + lin[ x ][ y ] + ( col[ x - 1 ][ j ] - col[ i ][ j ] ) + ( col[ x - 1 ][ y ] - col[ i ][ y ] ) ); while ( x <= n && y <= n ) { //sol = 0; x++; y++; sol = max( sol, lin[ i ][ y ] + lin[ x ][ y ] + ( col[ x - 1 ][ j ] - col[ i ][ j ] ) + ( col[ x - 1 ][ y ] - col[ i ][ y ] ) ) ; } } } int main() { citire(); rezolvare(); cout << sol; return 0; }