def max_sum(num: list):#本质还是最大连续子序列
    dp = [-99 for i in range(len(num) + 1)]
    dp[0] = num[0]
    for i in range(len(num)):
        dp[i] = max(num[i], dp[i - 1] + num[i])
    return max(dp)


n = int(input())
mat = [[] for i in range(n)]
for i in range(n):  # 矩阵的输入
    mat[i] = list(map(int, input().split(" ")))
ans = [0 for i in range(n)]
res = []
for i in range(n):
    ans = [0 for i in range(n)]
    for j in range(i, n):
        for k in range(n):
            ans[k] = ans[k] + mat[j][k]
        res.append(max_sum(ans))
print(max(res))