input = require('fs').readFileSync('/dev/stdin', 'utf8')

lines = input.split('\n')
N = lines.shift() * 1
A = lines.shift().split(' ')
B = lines.shift().split(' ')
ans = 0
C = Array(A.length).fill(0)
over = 0
for (i=0; i<N; i++) {
    C[i] = Math.min(A[i]*1, B[i]*1 + over)
    over = Math.max(B[i]*1 - (A[i]*1 - over), 0)
}
C[i] = Math.min(A[i]*1, over)
console.log(C.reduce((a, b) => a + b, 0))