n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
b = gets.chomp.split.map(&:to_i)
ar=a.dup.reverse
br=b.dup.reverse
def solve(a,b,n)
  ans = 0
  n.times do |i|
    if a[i] > b[i]
      ans += b[i]
    else
      ans += a[i]
      b[i] -= a[i]
      if a[i+1] > b[i]
        ans += b[i]
        a[i+1] -= b[i]
      else
        ans += a[i+1]
        a[i+1] = 0
      end
    end
  end
  ans
end

puts [solve(a,b,n), solve(ar, br, n)].max
#puts solve(a,b,n)
