#include<fstream>
using namespace std;
ifstream in("euro.in");
ofstream out("euro.out");
const int Nmax = 35001;
const int INF = 0x3f3f3f3f;
long long F[Nmax],D[Nmax];
int N,T,d[Nmax],st=1,dr=1;
int main(){
in>>N>>T;
for(int i=1;i<=N;i++) in>>F[i] , F[i]+=F[i-1];
for(int i=1;i<=N;i++){
D[i]=-INF;
while(st<dr && (D[d[st+1]]-D[d[st]]) >= i * (F[d[st+1]]-F[d[st]]) ) st++;
D[i] = D[ d[st] ] + i*(F[i]-F[ d[st] ]) - T;
while(st<dr && (D[i]-D[d[dr]]) >= i * (F[i]-F[d[dr]]) ) dr--;
d[++dr]=i;
}
out<<D[N]<<'\n';
return 0;
}