#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

template<class line_t, typename y_t, typename x_t, class F = less<y_t>>
struct LiChaoTree {
    const F compare = F();
    int n; vector<x_t> pos; vector<line_t> dat;
    void build(const vector<x_t>& pos_) {
        int n_ = pos_.size(); n = 1; while (n < n_) n *= 2; pos.resize(n); dat.assign(2 * n, line_t::identity());
        for (int i = 0; i < n_; ++i) { pos[i] = pos_[i]; } for (int i = n_; i < n; ++i) { pos[i] = pos[i - 1] + 1; }
    }
    void addLine(line_t&& line) { update(1, 0, n - 1, move(line)); }
    void update(int k, int l, int r, line_t&& line) {
        y_t vlnew = line(pos[l]), vlold = dat[k](pos[l]), vrnew = line(pos[r]), vrold = dat[k](pos[r]);
        if (!(compare(vlnew, vlold) || compare(vrnew, vrold))) return;
        if (!(compare(vlold, vlnew) || compare(vrold, vrnew))) { dat[k] = line; return; }
        int m = (l + r) / 2; y_t vmnew = line(pos[m]), vmold = dat[k](pos[m]);
        if (compare(vmnew, vmold)) { swap(line, dat[k]); swap(vlnew, vlold); }
        if (compare(vlnew, vlold)) { update(k * 2, l, m, move(line)); } else { update(k * 2 + 1, m + 1, r, move(line)); }
    }
    y_t query_x(x_t x) const { int i = lower_bound(pos.begin(), pos.end(), x) - pos.begin(); assert(pos[i] == x); return query_index(i); }
    y_t query_index(int i) const { return query(1, 0, n - 1, i); }
    y_t query(int k, int l, int r, int i) const {
        y_t v = dat[k](pos[i]); if (l == r) return v; int m = (l + r) / 2;
        y_t vc = i <= m ? query(2 * k, l, m, i) : query(2 * k + 1, m + 1, r, i); return compare(v, vc) ? v : vc;
    }
};

template<typename y_t, typename x_t, const y_t I_Y> struct Line {
    static constexpr Line<y_t, x_t, I_Y> identity() { return Line<y_t, x_t, I_Y>(0, I_Y); }
    y_t a, b;
    constexpr Line(y_t a, y_t b) : a(a), b(b) {}
    bool operator ==(const Line<y_t, x_t, I_Y>& rhs) const { return a == rhs.a && b == rhs.b; }
    y_t operator ()(x_t x) const {
        return *this == identity() ? I_Y : (x - a) * (x - a) + b;
    }
};

using L = Line<ll, int, INT64_MAX>;
using LCT = LiChaoTree<L, ll, int>;

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

    LCT lct;
    lct.build(h);
    lct.addLine(L(h[0], 0));
    rep(i, 1, N) {
        ll v = lct.query_index(i);
        if (i != N - 1) lct.addLine(L(h[i], v + C));
        else write(v + C);
    }
}

Measured memory_bytes: 10240