function Main(s) {
	s = s.split("\n");
	s[0] = s[0].split(" ").map(a => parseInt(a));
	var a = s[1] = s[1].split(" ").map(a => parseInt(a));
	const n = s[0][0];
	const x = s[0][1];
	var ans = 0;
	if(a[0] > x){
		ans += a[0] - x;
		a[0] = x;
	}
	for(var i = 1; i < n; i++){
		if(a[i-1] + a[i] > x){
			ans += a[i-1] + a[i] - x;
			a[i] = x - a[i-1];
		}
	}
	console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));