#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5+5;
typedef long long ll;
struct line{
    ll m,n;
    line(ll _m = 0, ll _n = 0){
        m = _m,n = _n;
    }
}A[maxn];
ll get_y(const line &a,const int &x){
    return a.m*x+a.n;
}
bool ok(const line &a,const line &b,const line &c){
    return (a.m-b.m)*(c.n-a.n)<=(a.m-c.m)*(b.n-a.n);
}
int l,r;
void add(const line f){
    while(l < r && ok(A[r-1],A[r],f)){
        r--;
    }
    r++;
    A[r] = f;
}
line query(const int x){
    while(l < r && get_y(A[l],x)>get_y(A[l+1],x))
        l++;
    return A[l];
}
ll sq(int x){
    return (ll)x*x;
}
int h[maxn];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen(".in","r",stdin);
    int N;
    ll C;
    cin >> N >> C;
    for (int i = 1; i <= N;i++){
        cin >> h[i];
    }
    A[1] = line(-2*h[1],sq(h[1]));
    l = r = 1;
    ll mx = 0;
    for (int i = 2; i <= N;i++){
        ll q = get_y(query(h[i]),h[i]);
        mx = q+C+sq(h[i]);
        add(line(-2*h[i],mx+sq(h[i])));
    }
    cout << mx;
    return 0;
}
