"use strict"

const arg_str = require('fs').readFileSync('/dev/stdin', 'UTF-8')
const args_lines = arg_str.split('\n')
const n = args_lines[0]
const monsters = args_lines[1].split(' ')
const stocks = args_lines[2].split(' ')

let total_kill_cnt = 0
let index = 0

stocks.forEach((item, index)=>{
  // i番目の街を攻撃
  if(parseInt(monsters[index]) < parseInt(stocks[index])){
    const kill_cnt = parseInt(monsters[index])
    total_kill_cnt += kill_cnt
    stocks[index] -= kill_cnt
    monsters[index] -= kill_cnt
  }else{
    const kill_cnt = parseInt(stocks[index])
    total_kill_cnt += kill_cnt
    stocks[index] -= kill_cnt
    monsters[index] -= kill_cnt
  }
  // 余力があればi+1番目の街を攻撃
  if(parseInt(stocks[index]) > 0 && index + 1 <= monsters.length - 1){
    if(monsters[index+1] < stocks[index]){
      const kill_cnt = parseInt(monsters[index+1])
      total_kill_cnt += kill_cnt
      stocks[index] -= kill_cnt
      monsters[index+1] -= kill_cnt
    }else{
      const kill_cnt = parseInt(stocks[index])
      total_kill_cnt += kill_cnt
      stocks[index] -= kill_cnt
      monsters[index+1] -= kill_cnt
    }
  }
})

console.log(total_kill_cnt)