#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define x first
#define y second

const int maxn = 1000005;
const ll INF = (ll)(1e17);
const int N = maxn;

pll tree[maxn << 2];

ll f(pll line, int x){
    return line.x * x + line.y;
}

void update(pll line, int lo = 1, int hi = N, int i = 1){
    int m = (lo + hi) >> 1;
    bool left = f(line, lo) < f(tree[i], lo);
    bool mid = f(line, m) < f(tree[i], m);

    if(mid) swap(tree[i], line);
    if(hi>lo){
        if(left != mid) update(line, lo, m, i << 1);
        else update(line, m + 1, hi, i << 1 | 1);
    }
}

ll query(int x, int lo = 1, int hi = N, int i = 1){
    int m = (lo+hi) >> 1;
    ll curr = f(tree[i], x);
    if(hi>lo){
        if(x<m) return min(curr, query(x, lo, m, i << 1));
        else return min(curr, query(x, m + 1, hi, i << 1 | 1));
    }else return curr;
}

int main(){
    int n;
    ll C;
    cin>>n>>C;
    vector<ll> dp(n, 0), h(n);
    for(int i=0; i<n; i++){
        cin>>h[i];
        if(i!=0) dp[i] = C + h[i]*h[i] + query(h[i]);
        update({-2*h[i], dp[i]+h[i]*h[i]});
    }
    cout<<dp[n-1];
}
