n = gets.to_i
cities = gets.split(' ').map(&:to_i)
braves = gets.split(' ').map(&:to_i)
count = 0
n.times do |i|
  brave = braves[i]
  2.times do |j|
    city = cities[i + j]
    monster = city <= brave ? city : brave
    brave -= monster
    cities[i + j] = city - monster
    count += monster
  end
end
puts count