#include<iostream>
#include<cstdio>
#include<cstring>
#define MAX 2501
using namespace std;
int N,Ans;
int M,F[MAX],G[MAX];
void zuixiaodaijia()
{
int min;
F[1]=G[1]+G[0];
for (int i=2;i<=N;i++)
{
min=0x7fffff;
for (int k=0;k<=i-1;k++)
{
if (F[k]+G[i-k]+G[0]<min)
min=F[k]+G[i-k]+G[0];
}
F[i]=min;
}
Ans=F[N]-G[0];
}
int main()
{
freopen("cowriver.in","r",stdin);
freopen("cowriver.out","w",stdout);
cin >> N >> G[0];
for (int i=1;i<=N;i++)
{
cin >> M;
G[i]=G[i-1]+M;
}
zuixiaodaijia();
cout << Ans << endl;
return 0;
}