#pragma GCC target("avx2,avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln = '\n';
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) {if (a < b) {a = b; return true;} return false;}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) {if (a > b) {a = b; return true;} return false;}
struct Fast_ios {Fast_ios() {cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);};} fast_ios;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

template <typename Int, bool isMin>
struct ConvexHullTrick {
    #define fi first
    #define se second
    using P = pair<Int, Int>;
    deque<P> H;
    bool empty() const {return H.empty();}
    void clear() {H.clear();}

    inline int sgn(Int x){return x == 0 ? 0 : (x < 0 ? -1 : 1);}

    using DD = long double;
    inline bool check(const P &a,const P &b,const P &c) {
        if (b.se==a.se||c.se==b.se)
        return sgn(b.fi-a.fi)*sgn(c.se-b.se) >= sgn(c.fi-b.fi)*sgn(b.se-a.se);

        //return (b.fi-a.fi)*(c.se-b.se) >= (b.se-a.se)*(c.fi-b.fi);
        return
        DD(b.fi-a.fi)*sgn(c.se-b.se)/DD(abs(b.se-a.se)) >=
        DD(c.fi-b.fi)*sgn(b.se-a.se)/DD(abs(c.se-b.se));
    }

    void addLine(Int m, Int b) {
        if (!isMin) m *= -1, b *= -1;
        P line(m,b);
        if (empty()) {
            H.emplace_front(line);
            return;
        }
        if (H.front().fi <= m) {
            if (H.front().fi == m) {
                if (H.front().se <= b) return;
                H.pop_front();
            }
            while ((int)H.size() >= 2 && check(line,H.front(),H[1])) H.pop_front();
            H.emplace_front(line);
        } else {
            assert(m <= H.back().fi);
            if(H.back().fi == m) {
                if(H.back().se<=b) return;
                H.pop_back();
            }
            while ((int)H.size() >= 2 && check(H[H.size()-2],H.back(),line)) H.pop_back();
            H.emplace_back(line);
        }
    }

    inline Int getY(const P &a, const Int &x) {
        return a.fi*x + a.se;
    }

    Int query(Int x) {
        assert(!empty());
        int l = -1, r = (int)H.size()-1;
        while(r - l > 1) {
            int m = (l+r)>>1;
            if(getY(H[m],x) >= getY(H[m+1],x)) l = m;
            else r = m;
        }
        if(isMin) return getY(H[r],x);
        return -getY(H[r],x);
    }

    Int queryMonotoneInc(Int x) {
        assert(!empty());
        while((int)H.size() >= 2 && getY(H.front(),x) >= getY(H[1],x)) H.pop_front();
        if(isMin) return getY(H.front(),x);
        return -getY(H.front(),x);
    }

    Int queryMonotoneDec(Int x) {
        assert(!empty());
        while((int)H.size() >= 2 && getY(H.back(),x) >= getY(H[H.size()-2],x)) H.pop_back();
        if(isMin) return getY(H.back(),x);
        return -getY(H.back(),x);
    }
    #undef fi
    #undef se
};

///////////////////////////////////////////////////////////////////////////////////

void EDPC_Z() {
    ll N,C; cin >> N >> C;
    vector<ll> h(N);
    rep(i,N) cin >> h[i];

    vector<ll> dp(N);
    ConvexHullTrick<ll,true> CHT;
    CHT.addLine(-h[0]*2,h[0]*h[0]);
    for (int i = 1; i < N; i++) {
        dp[i] = CHT.queryMonotoneInc(h[i]) + h[i]*h[i] + C;
        CHT.addLine(-h[i]*2,h[i]*h[i]+dp[i]);
    }

    cout << dp[N-1] << ln;
}

int main() {
    EDPC_Z();
}

Measured memory_bytes: 8360