Public Class Program
  Shared Sub Main()
    Dim n As Long = Long.Parse(Console.ReadLine())
    Dim arrayA As Long() = Array.ConvertAll(Of String, Long)(Console.ReadLine().Split(" "), AddressOf Long.Parse)
    Dim arrayB As Long() = Array.ConvertAll(Of String, Long)(Console.ReadLine().Split(" "), AddressOf Long.Parse)
    Dim remainder As Long = arrayA(0)
    Dim output As Long = 0
    For i As Long = 0 To n - 1
      remainder += arrayA(i + 1)
      remainder -= arrayB(i)
      If remainder < 0 Then 
        output += (arrayB(i) + remainder)
        remainder = 0
      Else
        output += arrayB(i)
      End If
      If remainder - arrayA(i + 1) > 0 Then remainder = arrayA(i + 1)
    Next
    Console.WriteLine(output.ToString())
  End Sub
End Class