#include<iostream>
#include<vector>
#include<algorithm>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

int main()
{
  int n;
  cin >> n;
  int a[n][n];
  int dp[n][n];
  int mex = -100000000;
  rep(i,n)rep(j,n)
    {
      cin >> a[i][j];
      mex = max(mex,a[i][j]);
    }
  if(n == 1)
    {
      cout << a[0][0] << endl;
      return 0;
    }

  rep(i,n)
    {
      dp[i][0] = a[i][0];
      REP(j,1,n)
	{
	  dp[i][j] = dp[i][j-1] + a[i][j];
	  mex = max(mex,dp[i][j]);
	}
    }

  REP(i,1,n)rep(j,n)dp[i][j] = dp[i][j] + dp[i-1][j],mex = max(mex,dp[i][j]);

  for(int i=n-1;i>=0;i--)
    {
      for(int j=n-1;j>=0;j--)	
	{
	  for(int y=i;y>=0;y--)
	    {
	      for(int x=j;x>=0;x--)
		{
		  int a,b,c;
		  a = x-1>=0?dp[i][x-1]:0;
		  b = y-1>=0?dp[y-1][j]:0;
		  c = (x-1>=0 && y-1>=0)?dp[y-1][x-1]:0;
		  int area = dp[i][j] - (a+b) + c;
		  mex = max(area,mex);		  
		}
	    }
	}
    }


  cout << mex << endl;  
  return 0;
}