'''
# 1931번 회의실 배정
n = int(input())
arr = [[0 for col in range (n)] for row in range (n)]
brr = [[]*n]*n
memory = 0
count = 0
for i in range(n):
arr[i] = list(map(int, input().split(" ")))
for i in range(n):
for j in range(n):
if arr[i][1] <= arr[j][0]:
brr[i].append(arr[j][1])
for i in range(n):
for j in range(n):
if brr[i][j] != 0:
count += 1
if memory < count:
memory = count
else:
count = 0
count = 0
print(brr)
print (memory)
memory = []
count = []
n = int(input())
arr = [0,0]*n
for i in range(n):
arr = list(map(int, input().split(" ")))
for i in range(True):
for j in range(n):
if arr[i][1] <= arr[j][0]:
memory.append(arr[j][0])
n = int(input())
arr = [0,0]*n
for i in range(n):
arr = list(map(int, input().split()))
arr.sort(reverse=True)
brr = [0, [0,0]]*n
for i in range(n):
brr[i, arr[i]]
arr = input().split(" ")
m = arr[0].replace('5','6')
n = arr[1].replace('5','6')
max1 = int(m)+int(n)
m1 = arr[0].replace('6','5')
n1 = arr[1].replace('6','5')
min1 = int(m1)+int(n1)
print(min1, max1)
T = int(input())
c = [0]*T
q = 0
d = 0
n = 0
p = 0
for i in range(T):
c = int(input())
while(c!=0):
if c>=25:
c-=25
q+=1
elif c>=10 and c<25:
c -= 10
d += 1
elif c<10 and c>=5:
c -= 5
n += 1
else:
c -= 1
p += 1
print(q,d,n,p)
q,d,n,p = 0
T = int(input())
q=0
d=0
n=0
p=0
for i in range(T):
c = int(input())
while(c!=0):
if c>=25:
q = c//25
c = c%25
elif c>=10 and c<25:
d = c//10
c = c%10
elif c<10 and c>=5:
n = c//5
c = c%5
else:
p = c
c -= p
print(q,d,n,p)
q=0
d=0
n=0
p=0
n = int(input())
tree = list(map(int, input().split(" ")))
tree.sort(reverse=True)
print(tree[0]+)
'''
n = int(input())
arr = [[0 for col in range (n)] for row in range (n)]
for i in range (n):
arr[i] = list(map(int, input().split(" ")))
crnt = 0
d = []
d = arr[0][0]
for i in range(n):
if d[crnt]>arr[0][i]:
d[crnt] += arr[0][i]
else: