#ifndef INCLUDE_TEMPLATE
#define INCLUDE_TEMPLATE

// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

using i128 = __int128;

istream& operator >>(istream &is, i128 &i) {
    ll a;
    is >> a;
    i = a;
    return is;
}

ostream& operator <<(ostream &os, i128 i) {
    ll a = (ll)i;  // WARNING!!
    os << a;
    return os;
}

#endif

struct LiChaoTree {
    using Line = PLL;
    
    struct Node {
        Line line;
        i128 lx, rx;
        Node *l, *r;
        Node(Line line, i128 lx, i128 rx) : lx(lx), rx(rx), line(line), l(nullptr), r(nullptr) {}
    };
    
    function<i128(i128, i128)> comp; // maybe min or max
    function<bool(i128, i128)> comp_b;
    i128 inf, max_x, id_ele;
    Line init;
    Node *root;

    LiChaoTree(function<i128(i128, i128)> comp, i128 inf, i128 arg_max_x, i128 id_ele, Line init)
        : comp(comp), init(init), inf(inf), id_ele(id_ele)
    {
        max_x = 1;
        while(max_x < arg_max_x) max_x *= 2;
        comp_b = [&](i128 a, i128 b) { return this->comp(a, b) == a; };
        root = new Node(init, 0, max_x);

    }

    i128 calc_y(Line line, i128 x) {
        i128 a, b;
        tie(a, b) = line;
        return a * x + b; 
    }

    i128 calc_y(Node *node, i128 x) { return calc_y(node->line, x); }
    
    Node* add_line(Line line, Node *node, i128 lx, i128 rx) {
        if(node == nullptr) return new Node(line, lx, rx);

        i128 mx = (lx + rx) / 2;

        bool lcmp = comp_b(calc_y(line, lx), calc_y(node, lx));
        bool mcmp = comp_b(calc_y(line, mx), calc_y(node, mx));
        bool rcmp = comp_b(calc_y(line, rx), calc_y(node, rx));

        if(lcmp && rcmp) {
            node->line = line;
            return node;
        }
        if(!lcmp && !rcmp) return node;
        if(mcmp) {
            swap(line, node->line);
            lcmp = !lcmp;
            rcmp = !rcmp;
        }
        if(lcmp) {
            auto l = node->l;
            node->l = add_line(line, l, lx, mx);
        } else {
            auto r = node->r;
            node->r = add_line(line, r, mx, rx);
        }
        return node;
    }

    Node* add_line_seg(Line line, Node *cur, i128 qlx, i128 qrx, i128 lx, i128 rx) {
        if(cur == nullptr) cur = new Node(init, lx, rx);
        if(qrx <= cur->lx || cur->rx <= qlx) return cur;
        if(qlx <= cur->lx && cur->rx <= qrx) return add_line(line, cur, lx, rx);
        auto mx = (lx + rx) / 2;
        cur->l = add_line_seg(line, cur->l, qlx, qrx, lx, mx);
        cur->r = add_line_seg(line, cur->r, qlx, qrx, mx, rx);
        return cur;
    }

    Node* add_line(Line line) { return add_line(line, root, 0, max_x); }

    Node* add_line_seg(Line line, i128 qlx, i128 qrx) { return add_line_seg(line, root, qlx, qrx, 0, max_x); }

    i128 query(i128 qx) {
        i128 lx = 0, rx = max_x;
        Node *cur = root;
        i128 ret = id_ele;
        while(cur != nullptr) {
            i128 tmp = calc_y(cur, qx);
            ret = comp(ret, tmp);
            if(rx - lx == 1) break;
            i128 mx = (lx + rx) / 2;
            if(lx <= qx && qx < mx) {
                rx = mx;
                cur = cur->l;
            } else {
                lx = mx;
                cur = cur->r;
            }
        }
        return ret;
    }
};

// solution for https://atcoder.jp/contests/dp/tasks/dp_z
const i128 inf = 5e18;
LiChaoTree lct([](i128 a, i128 b) { return min(a, b); }, inf, inf, inf, PLL(inf, inf));

int main() {
    i128 N, C;
    cin >> N >> C;
    V<i128> H(N);
    for(auto &&ele : H) cin >> ele;
    V<i128> dp(N + 1);
    dp[1] = 0;
    lct.add_line(PLL(-2 * H[0],  H[0] * H[0] + C));

    multiset<i128> lset;
    multiset<i128, greater<i128>> gset;
    for(ll i = 1; i < N; i++) {
        lset.insert(H[i]);
        gset.insert(H[i]);
    }

    auto get_range = [&] { return make_pair(*lset.begin(), *gset.begin()); };
    auto del_ele = [&](i128 e) {
        auto lite = lset.find(e);
        auto gite = gset.find(e);
        lset.erase(lite);
        gset.erase(gite);
    };

    for(i128 i = 2; i <= N; i++) {
        i128 h = H[i - 1];
        dp[i] = lct.query(h) + h * h;
        del_ele(h);
        i128 l, r;
        tie(l, r) = get_range();
        lct.add_line(PLL(-2 * h, h * h + C + dp[i]));
    }

    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 33664