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)
    a = A[i] * 1 - over
    if (a > 0) {
        if (B[i] * 1 - a > 0) {
            over = B[i] * 1 - a
        } else {
            over = 0
        }
    } else {
        over = B[i] * 1
    }
}
C[i] = Math.min(A[i]*1, over)
console.log(C.reduce((a, b) => a + b, 0))