n = gets.chomp.to_i
@a_array = gets.chomp.split(' ').map(&:to_i)
@b_array = gets.chomp.split(' ').map(&:to_i)

@output = 0

@b_array.each_with_index do |b, i|
  carry_over = b - @a_array[i]
  if carry_over <= 0 # b が a を超えない場合
    @output += b
  else # b が a を超えている場合
    if @a_array[i+1] >= carry_over
      @output += b
      @a_array[i+1] -= (b - @a_array[i])
    else
      @output += @a_array[i] + @a_array[i+1]
      @a_array[i+1] = 0
    end
  end
end

puts @output
