const maxn=2500+10;
var a,t:array[0..maxn] of longint;
x,n,m,i,j:longint;
begin
assign(input,'cowriver.in');reset(input);
assign(output,'cowriver.out');rewrite(output);
readln(n,m);
t[0]:=m;
for i:=1 to n do
begin
read(x);
t[i]:=t[i-1]+x;
end;
for i:=0 to n do inc(t[i],m);
fillchar(a,sizeof(a),26);
a[0]:=0;
for i:=1 to n do
if a[i]>t[i] then
begin
for j:=i to n do
if a[j]>a[j-i]+t[i] then a[j]:=a[j-i]+t[i];
end;
writeln(a[n]-m);
close(output);
end.