n=gets.to_i-1 m=0 a,b=$<.map{|e|e.split.map(&:to_i).tap{|a,b|m=[m,a+b].max}}.transpose c,d=[a,b].map &:sum p d-[0,d-c,m-c].max+1