# frozen_string_literal: true

_ = gets
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
count = 0

b.each_with_index do |i, idx|
  if i > a[idx]
    rest = i - a[idx]

    if rest > a[idx + 1]
      count += a[idx] + a[idx + 1]
      a[idx + 1] = 0
    else
      a[idx + 1] -= rest
      count += i
    end
  else
    count += i
  end
end

puts count