import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] a = new long[n+1];
    //int sum = 0;
    for (int i = 0;i<n+1;i++){
      a[i] = sc.nextLong();
      //sum += a[i];
    }
    long b;
    long ans=0;
    long kill;
    for (int i = 0;i<n;i++){
      b = sc.nextLong();
      kill = Math.min(a[i],b);
      a[i] -= kill;
      ans += kill;
      if (b != kill){
        b -= kill;
        kill = Math.min(a[i+1],b);
        a[i+1] -= kill;
        ans += kill;
      }
    }
    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();
    long[] a = new long[n+1];
    //int sum = 0;
    for (int i = 0;i<n+1;i++){
      a[i] = sc.nextLong();
      //sum += a[i];
    }
    long b;
    long ans=0;
    long kill;
    for (int i = 0;i<n;i++){
      b = sc.nextLong();
      kill = Math.min(a[i],b);
      a[i] -= kill;
      ans += kill;
      if (b != kill){
        b -= kill;
        kill = Math.min(a[i+1],b);
        a[i+1] -= kill;
        ans += kill;
      }
    }
    System.out.println(ans);
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] a = new long[n+1];
    //int sum = 0;
    for (int i = 0;i<n+1;i++){
      a[i] = sc.nextLong();
      //sum += a[i];
    }
    long b;
    long ans=0;
    long kill;
    for (int i = 0;i<n;i++){
      b = sc.nextLong();
      kill = Math.min(a[i],b);
      a[i] -= kill;
      ans += kill;
      if (b != kill){
        b -= kill;
        kill = Math.min(a[i+1],b);
        a[i+1] -= kill;
        ans += kill;
      }
    }
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] a = new long[n+1];
    //int sum = 0;
    for (int i = 0;i<n+1;i++){
      a[i] = sc.nextLong();
      //sum += a[i];
    }
    long b;
    long ans=0;
    long kill;
    for (int i = 0;i<n;i++){
      b = sc.nextLong();
      kill = Math.min(a[i],b);
      a[i] -= kill;
      ans += kill;
      if (b != kill){
        b -= kill;
        kill = Math.min(a[i+1],b);
        a[i+1] -= kill;
        ans += kill;
      }
    }
    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 long[] a = new long[n+1]; a new long[n+1] n+1 n 1 for (int i = 0;i<n+1;i++){
      a[i] = sc.nextLong();
      //sum += a[i];
    } int i = 0; int i = 0; i 0 i<n+1 i n+1 n 1 i++ i++ i {
      a[i] = sc.nextLong();
      //sum += a[i];
    } {
      a[i] = sc.nextLong();
      //sum += a[i];
    } a[i] = sc.nextLong() a[i] a i sc.nextLong() sc.nextLong sc long b; b long ans=0; ans 0 long kill; kill for (int i = 0;i<n;i++){
      b = sc.nextLong();
      kill = Math.min(a[i],b);
      a[i] -= kill;
      ans += kill;
      if (b != kill){
        b -= kill;
        kill = Math.min(a[i+1],b);
        a[i+1] -= kill;
        ans += kill;
      }
    } int i = 0; int i = 0; i 0 i<n i n i++ i++ i {
      b = sc.nextLong();
      kill = Math.min(a[i],b);
      a[i] -= kill;
      ans += kill;
      if (b != kill){
        b -= kill;
        kill = Math.min(a[i+1],b);
        a[i+1] -= kill;
        ans += kill;
      }
    } {
      b = sc.nextLong();
      kill = Math.min(a[i],b);
      a[i] -= kill;
      ans += kill;
      if (b != kill){
        b -= kill;
        kill = Math.min(a[i+1],b);
        a[i+1] -= kill;
        ans += kill;
      }
    } b = sc.nextLong() b sc.nextLong() sc.nextLong sc kill = Math.min(a[i],b) kill Math.min(a[i],b) Math.min Math a[i] a i b a[i] -= kill a[i] a i kill ans += kill ans kill if (b != kill){
        b -= kill;
        kill = Math.min(a[i+1],b);
        a[i+1] -= kill;
        ans += kill;
      } b != kill b kill {
        b -= kill;
        kill = Math.min(a[i+1],b);
        a[i+1] -= kill;
        ans += kill;
      } b -= kill b kill kill = Math.min(a[i+1],b) kill Math.min(a[i+1],b) Math.min Math a[i+1] a i+1 i 1 b a[i+1] -= kill a[i+1] a i+1 i 1 kill ans += kill ans kill 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();
    long[] a = new long[n+1];
    //int sum = 0;
    for (int i = 0;i<n+1;i++){
      a[i] = sc.nextLong();
      //sum += a[i];
    }
    long b;
    long ans=0;
    long kill;
    for (int i = 0;i<n;i++){
      b = sc.nextLong();
      kill = Math.min(a[i],b);
      a[i] -= kill;
      ans += kill;
      if (b != kill){
        b -= kill;
        kill = Math.min(a[i+1],b);
        a[i+1] -= kill;
        ans += kill;
      }
    }
    System.out.println(ans);
  }
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] a = new long[n+1];
    //int sum = 0;
    for (int i = 0;i<n+1;i++){
      a[i] = sc.nextLong();
      //sum += a[i];
    }
    long b;
    long ans=0;
    long kill;
    for (int i = 0;i<n;i++){
      b = sc.nextLong();
      kill = Math.min(a[i],b);
      a[i] -= kill;
      ans += kill;
      if (b != kill){
        b -= kill;
        kill = Math.min(a[i+1],b);
        a[i+1] -= kill;
        ans += kill;
      }
    }
    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();
    long[] a = new long[n+1];
    //int sum = 0;
    for (int i = 0;i<n+1;i++){
      a[i] = sc.nextLong();
      //sum += a[i];
    }
    long b;
    long ans=0;
    long kill;
    for (int i = 0;i<n;i++){
      b = sc.nextLong();
      kill = Math.min(a[i],b);
      a[i] -= kill;
      ans += kill;
      if (b != kill){
        b -= kill;
        kill = Math.min(a[i+1],b);
        a[i+1] -= kill;
        ans += kill;
      }
    }
    System.out.println(ans);
  }
}