import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int N = in.nextInt();
      int[] A = new int[N + 1];
      int[] B = new int[N];
      long killed = 0;

      for (int i = 0; i < A.length; ++i) {
        A[i] = in.nextInt();
      }

      for (int i = 0; i < B.length; ++i) {
        B[i] = in.nextInt();
      }

      for (int i = 0; i < B.length; ++i) {
        int areaSum = A[i] + A[i + 1];

        killed += Math.min(B[i], areaSum);
        
        B[i] = Math.max(B[i] - A[i], 0);
        A[i + 1] = Math.max(A[i + 1] - B[i], 0);
      }

      System.out.println(killed);
    }
  }
} import java.util.Scanner; Scanner java.util public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int N = in.nextInt();
      int[] A = new int[N + 1];
      int[] B = new int[N];
      long killed = 0;

      for (int i = 0; i < A.length; ++i) {
        A[i] = in.nextInt();
      }

      for (int i = 0; i < B.length; ++i) {
        B[i] = in.nextInt();
      }

      for (int i = 0; i < B.length; ++i) {
        int areaSum = A[i] + A[i + 1];

        killed += Math.min(B[i], areaSum);
        
        B[i] = Math.max(B[i] - A[i], 0);
        A[i + 1] = Math.max(A[i + 1] - B[i], 0);
      }

      System.out.println(killed);
    }
  }
} Main public static void main (String[] args) {
    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int N = in.nextInt();
      int[] A = new int[N + 1];
      int[] B = new int[N];
      long killed = 0;

      for (int i = 0; i < A.length; ++i) {
        A[i] = in.nextInt();
      }

      for (int i = 0; i < B.length; ++i) {
        B[i] = in.nextInt();
      }

      for (int i = 0; i < B.length; ++i) {
        int areaSum = A[i] + A[i + 1];

        killed += Math.min(B[i], areaSum);
        
        B[i] = Math.max(B[i] - A[i], 0);
        A[i + 1] = Math.max(A[i + 1] - B[i], 0);
      }

      System.out.println(killed);
    }
  } main {
    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int N = in.nextInt();
      int[] A = new int[N + 1];
      int[] B = new int[N];
      long killed = 0;

      for (int i = 0; i < A.length; ++i) {
        A[i] = in.nextInt();
      }

      for (int i = 0; i < B.length; ++i) {
        B[i] = in.nextInt();
      }

      for (int i = 0; i < B.length; ++i) {
        int areaSum = A[i] + A[i + 1];

        killed += Math.min(B[i], areaSum);
        
        B[i] = Math.max(B[i] - A[i], 0);
        A[i + 1] = Math.max(A[i + 1] - B[i], 0);
      }

      System.out.println(killed);
    }
  } Scanner in = new Scanner(System.in); in new Scanner(System.in) while (in.hasNext()) {
      int N = in.nextInt();
      int[] A = new int[N + 1];
      int[] B = new int[N];
      long killed = 0;

      for (int i = 0; i < A.length; ++i) {
        A[i] = in.nextInt();
      }

      for (int i = 0; i < B.length; ++i) {
        B[i] = in.nextInt();
      }

      for (int i = 0; i < B.length; ++i) {
        int areaSum = A[i] + A[i + 1];

        killed += Math.min(B[i], areaSum);
        
        B[i] = Math.max(B[i] - A[i], 0);
        A[i + 1] = Math.max(A[i + 1] - B[i], 0);
      }

      System.out.println(killed);
    } in.hasNext() in.hasNext in {
      int N = in.nextInt();
      int[] A = new int[N + 1];
      int[] B = new int[N];
      long killed = 0;

      for (int i = 0; i < A.length; ++i) {
        A[i] = in.nextInt();
      }

      for (int i = 0; i < B.length; ++i) {
        B[i] = in.nextInt();
      }

      for (int i = 0; i < B.length; ++i) {
        int areaSum = A[i] + A[i + 1];

        killed += Math.min(B[i], areaSum);
        
        B[i] = Math.max(B[i] - A[i], 0);
        A[i + 1] = Math.max(A[i + 1] - B[i], 0);
      }

      System.out.println(killed);
    } int N = in.nextInt(); N in.nextInt() in.nextInt in int[] A = new int[N + 1]; A new int[N + 1] N + 1 N 1 int[] B = new int[N]; B new int[N] N long killed = 0; killed 0 for (int i = 0; i < A.length; ++i) {
        A[i] = in.nextInt();
      } int i = 0; int i = 0; i 0 i < A.length i A.length A A.length ++i ++i i {
        A[i] = in.nextInt();
      } {
        A[i] = in.nextInt();
      } A[i] = in.nextInt() A[i] A i in.nextInt() in.nextInt in for (int i = 0; i < B.length; ++i) {
        B[i] = in.nextInt();
      } int i = 0; int i = 0; i 0 i < B.length i B.length B B.length ++i ++i i {
        B[i] = in.nextInt();
      } {
        B[i] = in.nextInt();
      } B[i] = in.nextInt() B[i] B i in.nextInt() in.nextInt in for (int i = 0; i < B.length; ++i) {
        int areaSum = A[i] + A[i + 1];

        killed += Math.min(B[i], areaSum);
        
        B[i] = Math.max(B[i] - A[i], 0);
        A[i + 1] = Math.max(A[i + 1] - B[i], 0);
      } int i = 0; int i = 0; i 0 i < B.length i B.length B B.length ++i ++i i {
        int areaSum = A[i] + A[i + 1];

        killed += Math.min(B[i], areaSum);
        
        B[i] = Math.max(B[i] - A[i], 0);
        A[i + 1] = Math.max(A[i + 1] - B[i], 0);
      } {
        int areaSum = A[i] + A[i + 1];

        killed += Math.min(B[i], areaSum);
        
        B[i] = Math.max(B[i] - A[i], 0);
        A[i + 1] = Math.max(A[i + 1] - B[i], 0);
      } int areaSum = A[i] + A[i + 1]; areaSum A[i] + A[i + 1] A[i] A i A[i + 1] A i + 1 i 1 killed += Math.min(B[i], areaSum) killed Math.min(B[i], areaSum) Math.min Math B[i] B i areaSum B[i] = Math.max(B[i] - A[i], 0) B[i] B i Math.max(B[i] - A[i], 0) Math.max Math B[i] - A[i] B[i] B i A[i] A i 0 A[i + 1] = Math.max(A[i + 1] - B[i], 0) A[i + 1] A i + 1 i 1 Math.max(A[i + 1] - B[i], 0) Math.max Math A[i + 1] - B[i] A[i + 1] A i + 1 i 1 B[i] B i 0 System.out.println(killed) System.out.println System.out System System.out killed String[] args args public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int N = in.nextInt();
      int[] A = new int[N + 1];
      int[] B = new int[N];
      long killed = 0;

      for (int i = 0; i < A.length; ++i) {
        A[i] = in.nextInt();
      }

      for (int i = 0; i < B.length; ++i) {
        B[i] = in.nextInt();
      }

      for (int i = 0; i < B.length; ++i) {
        int areaSum = A[i] + A[i + 1];

        killed += Math.min(B[i], areaSum);
        
        B[i] = Math.max(B[i] - A[i], 0);
        A[i + 1] = Math.max(A[i + 1] - B[i], 0);
      }

      System.out.println(killed);
    }
  }
} public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int N = in.nextInt();
      int[] A = new int[N + 1];
      int[] B = new int[N];
      long killed = 0;

      for (int i = 0; i < A.length; ++i) {
        A[i] = in.nextInt();
      }

      for (int i = 0; i < B.length; ++i) {
        B[i] = in.nextInt();
      }

      for (int i = 0; i < B.length; ++i) {
        int areaSum = A[i] + A[i + 1];

        killed += Math.min(B[i], areaSum);
        
        B[i] = Math.max(B[i] - A[i], 0);
        A[i + 1] = Math.max(A[i + 1] - B[i], 0);
      }

      System.out.println(killed);
    }
  }
} Main
import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int N = in.nextInt();
      int[] A = new int[N + 1];
      int[] B = new int[N];
      long killed = 0;

      for (int i = 0; i < A.length; ++i) {
        A[i] = in.nextInt();
      }

      for (int i = 0; i < B.length; ++i) {
        B[i] = in.nextInt();
      }

      for (int i = 0; i < B.length; ++i) {
        int areaSum = A[i] + A[i + 1];

        killed += Math.min(B[i], areaSum);
        
        B[i] = Math.max(B[i] - A[i], 0);
        A[i + 1] = Math.max(A[i + 1] - B[i], 0);
      }

      System.out.println(killed);
    }
  }
}