#include using namespace std; int a[55][55],s1[55][55][55],s2[55][55][55],i,j,n,k,l,mx; int main() { cin >> n; mx=-(1 << 30); for (i=1;i<=n;i++) for (j=1;j<=n;j++) { cin >> a[i][j]; if (a[i][j]>mx) mx=a[i][j]; } for (i=1;i<=n;i++) for (j=i;j<=n;j++) for (k=1;k<=n;k++) s1[i][j][k]=s1[i][j-1][k]+a[j][k]; for (i=1;i<=n;i++) for (j=i;j<=n;j++) for (k=1;k<=n;k++) s2[i][j][k]=s2[i][j-1][k]+a[k][j]; for (i=1;i<=n;i++) for (j=1;j<=n;j++) for (k=1;k<=n-i;k++) mx=max(mx,s1[i][i+k][j]+s1[i][i+k][j+k]+s2[j][j+k][i]+s2[j][j+k][i+k]-a[i][j]-a[i][j+k]-a[i+k][j+k]-a[i+k][j]); cout << mx; return 0; }