#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#define FOR(i,a,b) for(i=(a);i<=(b);i++)
#define ROF(i,a,b) for(i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define N 100010
using namespace std;
typedef long long LL;
typedef long double LD;
int i;
LL L,dp[N],f[N];int n,a[N],q[N];
LL r1(int k,int j){return dp[k]-dp[j]+(f[k]+f[j]+L+L)*(f[k]-f[j]);}
LL r2(int k,int j){return 2*(f[k]-f[j]);}
int main()
{
ios::sync_with_stdio(false);
scanf("%d%lld",&n,&L);L++;int i,j;
FOR(i,1,n) scanf("%d",&a[i]);
f[0]=0;FOR(i,1,n) f[i]=f[i-1]+a[i]+1;
int h=1,t=1;q[1]=0;
FOR(i,1,n)
{
while (t-h+1>1&&r1(q[h+1],q[h])<f[i]*r2(q[h+1],q[h])) h++;
int j=q[h];
dp[i]=dp[j]+(f[i]-f[j]-L)*(f[i]-f[j]-L);
while (t-h+1&&r1(i,q[t])*r2(q[t],q[t-1])<r1(q[t],q[t-1])*r2(i,q[t])) t--;
q[++t]=i;
}
printf("%lld\n",dp[n]);
return 0;
}