#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,ma=-123456789;
cin>>n;
int a[n][n],b[n][n];
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
cin>>a[i][j];
for(int y=0;y<n;y++)
for(int x=0;x<n;x++)
if(x==0&&y==0)
b[y][x]=a[y][x];
else if(!x)
b[y][x]=b[y-1][x]+a[y][x];
else if(!y)
b[y][x]=b[y][x-1]+a[y][x];
else
b[y][x]=b[y-1][x]+b[y][x-1]-b[y-1][x-1]+a[y][x];
for(int x1=0;x1<n;x1++)
for(int y1=0;y1<n;y1++)
for(int x2=x1;x2<n;x2++)
for(int y2=y1;y2<n;y2++)
ma=max(ma,b[x2][y2]-b[x2][y1-1]-b[x1-1][y2]+b[x1-1][y1-1]);
cout<<ma;
}