#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
const int MAXNUM=10000000;
int s[310][310],f[310];
int main(void)
{
freopen("miner.in","r",stdin);
freopen("miner.out","w",stdout);
int i,j,i2,n,temp,maxget=0;
cin>>n;
for (i=1;i<=n;i++)
for (j=1;j<=n;j++)
{
cin>>temp;
if (temp==0)
temp=-MAXNUM;
s[i][j]=s[i-1][j]+temp;
}
for (i=1;i<=n;i++)
for (i2=i;i2<=n;i2++)
for (j=1;j<=n;j++)
{
f[j]=f[j-1]+s[i2][j]-s[i-1][j];
if (f[j]<0)
f[j]=0;
else
{
if (maxget<f[j])
maxget=f[j];
}
}
if (maxget>10)
maxget-=10;
else
maxget=0;
cout<<maxget<<endl;
return(0);
}