/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<62 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//最大値を求めたい場合は中身を修正するとややこしいので, 追加時に(-a, -b) を渡して取得時にさらに - を付けて求める
// Convex Hull Trick
/*
    - insert (a, b): add y = ax + b
    - query (x): min_i{a[i]*x + b}
*/
template<class T> struct CHT {
    struct Line {
        T a, b;
        Line(T a = 0,T b = 0) : a(a), b(b) { }
        T get(T x) {
            return a*x + b;
        }
    };
    
    struct Node {
        Line l;
        Node *lhs,*rhs;
        Node(Line l) : l(l), lhs(nullptr), rhs(nullptr){}
    };
    
    const T MIN, MAX, Inf;
    Node* root;
    
    CHT(T MIN, T MAX, T Inf) : MIN(MIN), MAX(MAX), Inf(Inf), root(nullptr) { }
    Node* insert(Node* p, T left, T right, Line& l){
        if(!p) return new Node(l);
        if (p->l.get(left) <= l.get(left) && p->l.get(right) <= l.get(right)) return p;
        if (p->l.get(left) >= l.get(left) && p->l.get(right) >= l.get(right)) {
            p->l = l;
            return p;
        }
        T mid = (left + right) / 2;
        if (p->l.get(mid) > l.get(mid)) swap(p->l , l);
        if (p->l.get(left) >= l.get(left)) p->lhs = insert(p->lhs, left, mid, l);
        else p->rhs = insert(p->rhs, mid+1, right, l);
        return p;
        
    }
    void insert(T a, T b){
        Line l(a, b);
        root = insert(root, MIN, MAX, l);
    }
    T query(Node* p, T left, T right, T x){
        if(!p) return Inf;
        if(left == right) return p->l.get(x);
        T mid = (left + right) / 2;
        if (x <= mid) return min(p->l.get(x), query(p->lhs, left, mid, x));
        else return min(p->l.get(x), query(p->rhs, mid+1, right, x));
    }
    T query(T x){
        return query(root, MIN, MAX, x);
    }
};

void solve() {
	int n; cin >> n;
    ll c; cin >> c;
    vector<int> h(n);
    rep(i, n) {
        cin >> h[i];
    }
    vector<int> dp(n, INF);
    dp[0] = 0;
    CHT<ll> cht(-inf, inf, inf);
    cht.insert((-2) * h[0], h[0] * h[0]);
    for(int i = 1; i < n; ++i) {
        dp[i] = cht.query(h[i]) + c + h[i] * h[i];
        //cerr << dp[i] << endl;
        //cerr << (-2LL) * h[i] << " " << h[i] * h[i] + dp[i] << endl;
        cht.insert((-2LL) * h[i], dp[i] + h[i] * h[i]);
    }
    cout << dp[n - 1] << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 12800