m=(1..n=gets.to_i).map{gets.split.map &:to_i}
o=m.map{|l|a=[];l.map{|i|(a.map!{|j|j+i}<<i).dup}}
p=o.transpose.map &:transpose
q=p.map{|l|l.map{|i|a=[];i.map{|j|(a.map!{|k|k+j}<<j).dup}}}
p q.flatten.max