program bzoj_1010; var q:array[0..50000]of longint; n,i,l,hd,tl:longint; f,pre:array[0..50000]of int64; functioncalc(i,j:longint):extended; begin exit((f[i]-f[j]+sqr(pre[i]+l+1)-sqr(pre[j]+l+1))/((pre[i]-pre[j])*2)); end; begin readln(n,l); for i:=1to n do begin read(pre[i]); inc(pre[i],pre[i-1]); end; for i:=1to n do inc(pre[i],i); hd:=0; tl:=0; for i:=1to n do begin while (hd<tl)and(calc(q[hd],q[hd+1])<pre[i]) do inc(hd); f[i]:=f[q[hd]]+sqr(pre[i]-pre[q[hd]]-l-1); while (tl>hd)and(calc(q[tl-1],q[tl])>calc(q[tl],i)) do dec(tl); inc(tl); q[tl]:=i; end; writeln(f[n]); end.