
import std.stdio, std.conv, std.string, std.algorithm, std.array, std.range;

void dump(long[][] arr) {
  for(int i = 0; i < arr.length; i++)
    for(int j = 0; j < arr[i].length; j++)
      writef("%2d%s", arr[i][j], j == arr[i].length - 1 ? "\n" : " ");
  writeln;
}

void main() {
  int t = readln.chomp.to!(int);
  long ans = long.min;
  long[][] arr;
  long[][] dp = new long[][](t + 1, t + 1);
  for(long i = 0; i < t; i++)
    arr ~= (readln.chomp.split(" ").map!(to!(long)).array) ~ [0L];
  arr ~= repeat(0L).take(t + 1).array;
  for(int i = t - 1; i >= 0; i--) {
    for (int j = t - 1; j >= 0; j--) {
      dp[i][j] += arr[i][j] + dp[i + 1][j] + dp[i][j + 1] - dp[i + 1][j + 1];
    }
  }
  for(int i = t; i >= 0; i--) {
    for(int j = t; j >= 0; j--) {
      for(int n = i; n <= t; n++) {
        for(int m = i; m <= t; m++) {
          ans = max(dp[i][j] - dp[n][j] - dp[i][m], ans);
        }
      }
    }
  }
  // dump(arr);
  // dump(dp);
  writeln(ans);
}