import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    long [] a = new long[n+1];
    long [] b = new long[n];
    long [] d = new long[n];
    for (int i=0;i<n+1;i++){
      a[i] = scan.nextLong();
    }
    for (int j=0;j<n;j++){
      b[j] = scan.nextLong();
    }
    long sum = 0;
    for (int k=0;k<n-1;k++){
      if (a[k] > d[k]){
        sum += d[k];
        a[k] -= d[k];
      }
      else{
        sum += a[k];
        d[k+1] = b[k];
        continue;
      }

      long c = b[k] - a[k];
      if (c >= 0){
        sum += a[k];
        d[k+1] += c;
      }
      else{
        sum += b[k];
      }
    }

    if (d[n-1] >= a[n-1]){
      sum += a[n-1];
      a[n-1] = 0;
    }
    else{
      sum += d[n-1];
      a[n-1] -= d[n-1];
    }
    
    if (b[n-1] > a[n-1] + a[n]){
      b[n-1] = a[n-1] + a[n];
    }
    sum += b[n-1];
    System.out.println(sum);

  }
} import java.util.*; util.* java public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    long [] a = new long[n+1];
    long [] b = new long[n];
    long [] d = new long[n];
    for (int i=0;i<n+1;i++){
      a[i] = scan.nextLong();
    }
    for (int j=0;j<n;j++){
      b[j] = scan.nextLong();
    }
    long sum = 0;
    for (int k=0;k<n-1;k++){
      if (a[k] > d[k]){
        sum += d[k];
        a[k] -= d[k];
      }
      else{
        sum += a[k];
        d[k+1] = b[k];
        continue;
      }

      long c = b[k] - a[k];
      if (c >= 0){
        sum += a[k];
        d[k+1] += c;
      }
      else{
        sum += b[k];
      }
    }

    if (d[n-1] >= a[n-1]){
      sum += a[n-1];
      a[n-1] = 0;
    }
    else{
      sum += d[n-1];
      a[n-1] -= d[n-1];
    }
    
    if (b[n-1] > a[n-1] + a[n]){
      b[n-1] = a[n-1] + a[n];
    }
    sum += b[n-1];
    System.out.println(sum);

  }
} Main public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    long [] a = new long[n+1];
    long [] b = new long[n];
    long [] d = new long[n];
    for (int i=0;i<n+1;i++){
      a[i] = scan.nextLong();
    }
    for (int j=0;j<n;j++){
      b[j] = scan.nextLong();
    }
    long sum = 0;
    for (int k=0;k<n-1;k++){
      if (a[k] > d[k]){
        sum += d[k];
        a[k] -= d[k];
      }
      else{
        sum += a[k];
        d[k+1] = b[k];
        continue;
      }

      long c = b[k] - a[k];
      if (c >= 0){
        sum += a[k];
        d[k+1] += c;
      }
      else{
        sum += b[k];
      }
    }

    if (d[n-1] >= a[n-1]){
      sum += a[n-1];
      a[n-1] = 0;
    }
    else{
      sum += d[n-1];
      a[n-1] -= d[n-1];
    }
    
    if (b[n-1] > a[n-1] + a[n]){
      b[n-1] = a[n-1] + a[n];
    }
    sum += b[n-1];
    System.out.println(sum);

  } main {
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    long [] a = new long[n+1];
    long [] b = new long[n];
    long [] d = new long[n];
    for (int i=0;i<n+1;i++){
      a[i] = scan.nextLong();
    }
    for (int j=0;j<n;j++){
      b[j] = scan.nextLong();
    }
    long sum = 0;
    for (int k=0;k<n-1;k++){
      if (a[k] > d[k]){
        sum += d[k];
        a[k] -= d[k];
      }
      else{
        sum += a[k];
        d[k+1] = b[k];
        continue;
      }

      long c = b[k] - a[k];
      if (c >= 0){
        sum += a[k];
        d[k+1] += c;
      }
      else{
        sum += b[k];
      }
    }

    if (d[n-1] >= a[n-1]){
      sum += a[n-1];
      a[n-1] = 0;
    }
    else{
      sum += d[n-1];
      a[n-1] -= d[n-1];
    }
    
    if (b[n-1] > a[n-1] + a[n]){
      b[n-1] = a[n-1] + a[n];
    }
    sum += b[n-1];
    System.out.println(sum);

  } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan long [] a = new long[n+1]; a new long[n+1] n+1 n 1 long [] b = new long[n]; b new long[n] n long [] d = new long[n]; d new long[n] n for (int i=0;i<n+1;i++){
      a[i] = scan.nextLong();
    } int i=0; int i=0; i 0 i<n+1 i n+1 n 1 i++ i++ i {
      a[i] = scan.nextLong();
    } {
      a[i] = scan.nextLong();
    } a[i] = scan.nextLong() a[i] a i scan.nextLong() scan.nextLong scan for (int j=0;j<n;j++){
      b[j] = scan.nextLong();
    } int j=0; int j=0; j 0 j<n j n j++ j++ j {
      b[j] = scan.nextLong();
    } {
      b[j] = scan.nextLong();
    } b[j] = scan.nextLong() b[j] b j scan.nextLong() scan.nextLong scan long sum = 0; sum 0 for (int k=0;k<n-1;k++){
      if (a[k] > d[k]){
        sum += d[k];
        a[k] -= d[k];
      }
      else{
        sum += a[k];
        d[k+1] = b[k];
        continue;
      }

      long c = b[k] - a[k];
      if (c >= 0){
        sum += a[k];
        d[k+1] += c;
      }
      else{
        sum += b[k];
      }
    } int k=0; int k=0; k 0 k<n-1 k n-1 n 1 k++ k++ k {
      if (a[k] > d[k]){
        sum += d[k];
        a[k] -= d[k];
      }
      else{
        sum += a[k];
        d[k+1] = b[k];
        continue;
      }

      long c = b[k] - a[k];
      if (c >= 0){
        sum += a[k];
        d[k+1] += c;
      }
      else{
        sum += b[k];
      }
    } {
      if (a[k] > d[k]){
        sum += d[k];
        a[k] -= d[k];
      }
      else{
        sum += a[k];
        d[k+1] = b[k];
        continue;
      }

      long c = b[k] - a[k];
      if (c >= 0){
        sum += a[k];
        d[k+1] += c;
      }
      else{
        sum += b[k];
      }
    } if (a[k] > d[k]){
        sum += d[k];
        a[k] -= d[k];
      }
      else{
        sum += a[k];
        d[k+1] = b[k];
        continue;
      } a[k] > d[k] a[k] a k d[k] d k {
        sum += d[k];
        a[k] -= d[k];
      } sum += d[k] sum d[k] d k a[k] -= d[k] a[k] a k d[k] d k {
        sum += a[k];
        d[k+1] = b[k];
        continue;
      } sum += a[k] sum a[k] a k d[k+1] = b[k] d[k+1] d k+1 k 1 b[k] b k continue; long c = b[k] - a[k]; c b[k] - a[k] b[k] b k a[k] a k if (c >= 0){
        sum += a[k];
        d[k+1] += c;
      }
      else{
        sum += b[k];
      } c >= 0 c 0 {
        sum += a[k];
        d[k+1] += c;
      } sum += a[k] sum a[k] a k d[k+1] += c d[k+1] d k+1 k 1 c {
        sum += b[k];
      } sum += b[k] sum b[k] b k if (d[n-1] >= a[n-1]){
      sum += a[n-1];
      a[n-1] = 0;
    }
    else{
      sum += d[n-1];
      a[n-1] -= d[n-1];
    } d[n-1] >= a[n-1] d[n-1] d n-1 n 1 a[n-1] a n-1 n 1 {
      sum += a[n-1];
      a[n-1] = 0;
    } sum += a[n-1] sum a[n-1] a n-1 n 1 a[n-1] = 0 a[n-1] a n-1 n 1 0 {
      sum += d[n-1];
      a[n-1] -= d[n-1];
    } sum += d[n-1] sum d[n-1] d n-1 n 1 a[n-1] -= d[n-1] a[n-1] a n-1 n 1 d[n-1] d n-1 n 1 if (b[n-1] > a[n-1] + a[n]){
      b[n-1] = a[n-1] + a[n];
    } b[n-1] > a[n-1] + a[n] b[n-1] b n-1 n 1 a[n-1] + a[n] a[n-1] a n-1 n 1 a[n] a n {
      b[n-1] = a[n-1] + a[n];
    } b[n-1] = a[n-1] + a[n] b[n-1] b n-1 n 1 a[n-1] + a[n] a[n-1] a n-1 n 1 a[n] a n sum += b[n-1] sum b[n-1] b n-1 n 1 System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    long [] a = new long[n+1];
    long [] b = new long[n];
    long [] d = new long[n];
    for (int i=0;i<n+1;i++){
      a[i] = scan.nextLong();
    }
    for (int j=0;j<n;j++){
      b[j] = scan.nextLong();
    }
    long sum = 0;
    for (int k=0;k<n-1;k++){
      if (a[k] > d[k]){
        sum += d[k];
        a[k] -= d[k];
      }
      else{
        sum += a[k];
        d[k+1] = b[k];
        continue;
      }

      long c = b[k] - a[k];
      if (c >= 0){
        sum += a[k];
        d[k+1] += c;
      }
      else{
        sum += b[k];
      }
    }

    if (d[n-1] >= a[n-1]){
      sum += a[n-1];
      a[n-1] = 0;
    }
    else{
      sum += d[n-1];
      a[n-1] -= d[n-1];
    }
    
    if (b[n-1] > a[n-1] + a[n]){
      b[n-1] = a[n-1] + a[n];
    }
    sum += b[n-1];
    System.out.println(sum);

  }
} public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    long [] a = new long[n+1];
    long [] b = new long[n];
    long [] d = new long[n];
    for (int i=0;i<n+1;i++){
      a[i] = scan.nextLong();
    }
    for (int j=0;j<n;j++){
      b[j] = scan.nextLong();
    }
    long sum = 0;
    for (int k=0;k<n-1;k++){
      if (a[k] > d[k]){
        sum += d[k];
        a[k] -= d[k];
      }
      else{
        sum += a[k];
        d[k+1] = b[k];
        continue;
      }

      long c = b[k] - a[k];
      if (c >= 0){
        sum += a[k];
        d[k+1] += c;
      }
      else{
        sum += b[k];
      }
    }

    if (d[n-1] >= a[n-1]){
      sum += a[n-1];
      a[n-1] = 0;
    }
    else{
      sum += d[n-1];
      a[n-1] -= d[n-1];
    }
    
    if (b[n-1] > a[n-1] + a[n]){
      b[n-1] = a[n-1] + a[n];
    }
    sum += b[n-1];
    System.out.println(sum);

  }
} Main
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    long [] a = new long[n+1];
    long [] b = new long[n];
    long [] d = new long[n];
    for (int i=0;i<n+1;i++){
      a[i] = scan.nextLong();
    }
    for (int j=0;j<n;j++){
      b[j] = scan.nextLong();
    }
    long sum = 0;
    for (int k=0;k<n-1;k++){
      if (a[k] > d[k]){
        sum += d[k];
        a[k] -= d[k];
      }
      else{
        sum += a[k];
        d[k+1] = b[k];
        continue;
      }

      long c = b[k] - a[k];
      if (c >= 0){
        sum += a[k];
        d[k+1] += c;
      }
      else{
        sum += b[k];
      }
    }

    if (d[n-1] >= a[n-1]){
      sum += a[n-1];
      a[n-1] = 0;
    }
    else{
      sum += d[n-1];
      a[n-1] -= d[n-1];
    }
    
    if (b[n-1] > a[n-1] + a[n]){
      b[n-1] = a[n-1] + a[n];
    }
    sum += b[n-1];
    System.out.println(sum);

  }
}
