function Main(input) {
	input = input.split("\n");
  	l1=input[0].split(" ");
    l2=input[1].split(" ");
	var n = parseInt(l1[0], 10);
  	var x=parseInt(l1[1],10);
  	var a= new Array(n);
  	for (var i=0; i<n; i++){
     	a[i]= parseInt(l2[i].split(" "), 10);
    }
  	var sum=0;
  	
  	if (a[0]>x){
      	sum+=a[0]-x;
     	a[0]=x;     	
    }
  	
  	for (var j=1; j<n; j++){
      if (a[j-1]+a[j]>x){
       	sum+=a[j]-(x-a[j-1]);
        a[j]=x-a[j-1];
      }
    }
  	console.log('%d',sum);
  }
Main(require("fs").readFileSync("/dev/stdin", "utf8"));