import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int [n+1];
    for(int i=0;i<=n;i++)
      a[i]=sc.nextInt();
    long ans=0;
    for(int i=0;i<n;i++){
      int x=sc.nextInt();
      long min=Math.min(x, a[i]);
      ans += min;
      x-=min;
      min=Math.min(x, a[i+1]);
      a[i+1] -= min;
      ans += min;
    }
    System.out.println(ans);
  }
} import java.util.*; util.* java public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int [n+1];
    for(int i=0;i<=n;i++)
      a[i]=sc.nextInt();
    long ans=0;
    for(int i=0;i<n;i++){
      int x=sc.nextInt();
      long min=Math.min(x, a[i]);
      ans += min;
      x-=min;
      min=Math.min(x, a[i+1]);
      a[i+1] -= min;
      ans += min;
    }
    System.out.println(ans);
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int [n+1];
    for(int i=0;i<=n;i++)
      a[i]=sc.nextInt();
    long ans=0;
    for(int i=0;i<n;i++){
      int x=sc.nextInt();
      long min=Math.min(x, a[i]);
      ans += min;
      x-=min;
      min=Math.min(x, a[i+1]);
      a[i+1] -= min;
      ans += min;
    }
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int [n+1];
    for(int i=0;i<=n;i++)
      a[i]=sc.nextInt();
    long ans=0;
    for(int i=0;i<n;i++){
      int x=sc.nextInt();
      long min=Math.min(x, a[i]);
      ans += min;
      x-=min;
      min=Math.min(x, a[i+1]);
      a[i+1] -= min;
      ans += min;
    }
    System.out.println(ans);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] a = new int [n+1]; a new int [n+1] n+1 n 1 for(int i=0;i<=n;i++)
      a[i]=sc.nextInt(); int i=0; int i=0; i 0 i<=n i n i++ i++ i a[i]=sc.nextInt(); a[i]=sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc long ans=0; ans 0 for(int i=0;i<n;i++){
      int x=sc.nextInt();
      long min=Math.min(x, a[i]);
      ans += min;
      x-=min;
      min=Math.min(x, a[i+1]);
      a[i+1] -= min;
      ans += min;
    } int i=0; int i=0; i 0 i<n i n i++ i++ i {
      int x=sc.nextInt();
      long min=Math.min(x, a[i]);
      ans += min;
      x-=min;
      min=Math.min(x, a[i+1]);
      a[i+1] -= min;
      ans += min;
    } {
      int x=sc.nextInt();
      long min=Math.min(x, a[i]);
      ans += min;
      x-=min;
      min=Math.min(x, a[i+1]);
      a[i+1] -= min;
      ans += min;
    } int x=sc.nextInt(); x sc.nextInt() sc.nextInt sc long min=Math.min(x, a[i]); min Math.min(x, a[i]) Math.min Math x a[i] a i ans += min ans min x-=min x min min=Math.min(x, a[i+1]) min Math.min(x, a[i+1]) Math.min Math x a[i+1] a i+1 i 1 a[i+1] -= min a[i+1] a i+1 i 1 min ans += min ans min System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int [n+1];
    for(int i=0;i<=n;i++)
      a[i]=sc.nextInt();
    long ans=0;
    for(int i=0;i<n;i++){
      int x=sc.nextInt();
      long min=Math.min(x, a[i]);
      ans += min;
      x-=min;
      min=Math.min(x, a[i+1]);
      a[i+1] -= min;
      ans += min;
    }
    System.out.println(ans);
  }
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int [n+1];
    for(int i=0;i<=n;i++)
      a[i]=sc.nextInt();
    long ans=0;
    for(int i=0;i<n;i++){
      int x=sc.nextInt();
      long min=Math.min(x, a[i]);
      ans += min;
      x-=min;
      min=Math.min(x, a[i+1]);
      a[i+1] -= min;
      ans += min;
    }
    System.out.println(ans);
  }
} Main
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int [n+1];
    for(int i=0;i<=n;i++)
      a[i]=sc.nextInt();
    long ans=0;
    for(int i=0;i<n;i++){
      int x=sc.nextInt();
      long min=Math.min(x, a[i]);
      ans += min;
      x-=min;
      min=Math.min(x, a[i+1]);
      a[i+1] -= min;
      ans += min;
    }
    System.out.println(ans);
  }
}