#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e3;
struct point{
long long a, b;
};
struct nod{
point line;
nod *left, *right;
nod(){
line = {MAX, MAX};
left = right = NULL;
}
};
typedef nod * node;
int n, t;
///Li Chao
long long f(point x, int t){
return 1LL * x.a * t + x.b;
}
node arb;
void add_line(point line, node Nod = arb, int st = 1, int dr = n){
int mij = (st + dr) / 2;
bool lef = f(line, st) < f(Nod->line, st);
bool mid = f(line, mij) < f(Nod->line, mij);
if(mid) swap(line, Nod->line);
if(st == dr) return ;
if(lef != mid){
if(Nod->left == NULL){
Nod->left = new nod;
Nod->left->line = line;
}
else add_line(line, Nod->left, st, mij);
}
else{
if(Nod->right== NULL){
Nod->right = new nod;
Nod->right->line = line;
}
else add_line(line, Nod->right, mij + 1, dr);
}
}
long long query(int x, node nod = arb, int st = 1, int dr = n){
int mij = (st + dr) / 2;
long long val = f(nod->line, x);
if(st == dr) return val;
if(nod->left != NULL && x <= mij) val = min(query(x, nod->left, st, mij), val);
else if(nod->right != NULL && x >= mij + 1) val = min(query(x, nod->right, mij + 1, dr), val);
return val;
}
int main()
{
freopen("euro.in", "r", stdin);
freopen("euro.out", "w", stdout);
scanf("%d%d", &n, &t);
int s = 0, x;
arb = new nod;
arb->line = {0, 0};
for(int i = 1; i <= n ; ++i){
scanf("%d", &x);
s += x;
long long q = -query(i);
long long dp = q + 1LL * s * i - t;
point nl = {s, -dp};
add_line(nl);
if(i == n) printf("%lld", dp);
}
return 0;
}