#include<bits/stdc++.h>

using namespace std;
#define N 200010
#define ll long long
#define ld long double

struct line
{
    ll a,b;
};

deque<line>dq;

ld giaoX(line u,line v)
{
    return (ld)(v.b-u.b)/(u.a-v.a);
}

ll vall(line u,ll x)
{
    return u.a*x+u.b;
}

void update(line u)
{
    while(dq.size()>=2&&giaoX(dq[dq.size()-1],u)<=giaoX(dq[dq.size()-2],u))dq.pop_back();
    dq.push_back(u);
}

ll tktp(ll x)
{
    while(dq.size()>=2&&giaoX(dq[0],dq[1])<x)dq.pop_front();
    return vall(dq[0],x);
}

ll h[N],dp[N],C;
int n;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cin>>n>>C;
    for(int i=1;i<=n;i++)cin>>h[i];
    dq.push_back({-2*h[1],dp[1]+h[1]*h[1]});
    for(int i=2;i<=n;i++)
    {
        ll u=tktp(h[i]);
        dp[i]=u+h[i]*h[i]+C;
        update({-2*h[i],dp[i]+h[i]*h[i]});
    }
    cout<<dp[n];
    return 0;
}
