mod=2000 ans=1500 n=gets.to_i a=gets.split.map{|i|i.to_i*mod}.sort+[10**9] b=gets.split.map{|i|i.to_i/2} for i in 1..n do pq=a.dup cnt=0 b.rotate(i).each{|e| l=pq.shift up=l+e*mod+1 pq.insert((0..n-1).bsearch{|x|pq[x]>=up},up) } cnt=pq.map{|x|x%mod}.max ans=cnt if ans>cnt end puts ans