let a=Int(readLine()!)!
var arr1=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}
var arr2=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}
var arr3 = arr1

var i = 0
var b = 0
var c = 0

for i in 0..<a {

  if( arr1[i] > arr2[i] ) {
    arr1[i] = arr1[i] - arr2[i]
  } else {
    var tmp = arr1[i]
    arr1[i] = 0
    arr2[i] = arr2[i] - tmp
    c = arr2[i]
    
    if( arr1[i+1] > c ) {
      arr1[i+1] = arr1[i+1] - c
    } else {
      arr1[i+1] = 0
      c = 0
    }
  }
}

for i in 0..<a + 1 {
  b += ( arr3[i] - arr1[i] )
}
print(b)
