hero = gets.to_i
monster = gets.split.map(&:to_i)
damage = gets.split.map(&:to_i)
sum_of_monster = monster.inject(0, :+)
still_alive_monster = 0
for i in 0...(monster.length - 1 )
  killed_monster = [damage[i] - monster[i], damage[i]].min
  cur_damage = damage[i] - monster[i]
  if cur_damage > 0
    killed_monster += monster[i + 1] - cur_damage
  end

  monster[i + 1] = [monster[i + 1] - killed_monster, 0].max
end

puts sum_of_monster - still_alive_monster