m=-1e9

n=int(input())

N=list(range(n))

B=[[0]*(n+1) for _ in range(n+1)]

for _ in N:

  A=list(map(int,input().split()))

  for j in N:

    s=0

    b=B[j]

    for k in N[j:]:

      s+=A[k]

      b[k]=max(b[k],0)+s

      m=max(b[k],m)

print(m)
def f(m,b):

  s=0

  for k in N[j:]:

    s+=A[k]

    b[k]=max(b[k],0)+s

    m=max(b[k],m)

  return m,b



m=-1e9

n=int(input())

N=list(range(n))

B=[[0]*(n+1) for _ in range(n+1)]

for _ in N:

  A=list(map(int,input().split()))

  for j in N: m,B[j]=f(m,B[j])

print(m)
m = -1e9
n = int(input())
N = list(range(n))
B = [[0] * (n + 1) for _ in range(n + 1)]
for _ in N:
    A = list(map(int, input().split()))
    for j in N:
        s = 0
        b = B[j]
        for k in N[j:]:
            s += A[k]
            b[k] = max(b[k], 0) + s
            m = max(b[k], m)
print(m)

def f(m, b):
    s = 0
    for k in N[j:]:
        s += A[k]
        b[k] = max(b[k], 0) + s
        m = max(b[k], m)
    return m, b


m = -1e9
n = int(input())
N = list(range(n))
B = [[0] * (n + 1) for _ in range(n + 1)]
for _ in N:
    A = list(map(int, input().split()))
    for j in N:
        m, B[j] = f(m, B[j])
print(m)

+def f(m, b): +    s = 0 +    for k in N[j:]: +        s += A[k] +        b[k] = max(b[k], 0) + s +        m = max(b[k], m) +    return m, b + + -        s = 0 -        b = B[j] -        for k in N[j:]: -            s += A[k] -            b[k] = max(b[k], 0) + s -            m = max(b[k], m) +        m, B[j] = f(m, B[j])