#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

// デフォルトで最大値取得の CHT
// 傾きと切片の pair
// lines は担当する区間 [l, r) で最大値を持つ ax + b の pair(a, b)
const int VMAX = 1e6 + 5;
template <typename T, typename G>
class ConvexHullTrick {
public:
    std::vector< std::pair<T, T> > lines;
    std::vector<G> xs;
    int n, sz;
    ConvexHullTrick(int _n, std::vector<G> _xs, std::pair<T, T> def={0, T(-HIGHINF)}) : n(_n + 1), xs(_xs) {
        sz = 1;
        while (sz < _n + 1) sz <<= 1;
        lines.resize(2 * sz - 1, def);
        xs.emplace_back(VMAX);
    }

    T func(G x, std::pair<T, T> coef) {
        return coef.first * x + coef.second;
    }

    void insert(T a, T b) {
        // cout << "insert line: " << a << "x + " << b << '\n';
        _insert(std::pair<T, T> (a, b), 0, 0, sz);
    }
    void _insert(std::pair<T, T> f, int k, int l, int r) {
        // cerr << k << ' ' << l << ' ' << r << '\n';
        P<T, T> g = lines[k];
        G leftx = xs[min(l, n - 1)], rightx = xs[min(r - 1, n - 1)];
        G midx = xs[min((l + r) >> 1, n - 1)];
        // cerr << "xs: " << leftx << ' ' << midx << ' ' << rightx << '\n';
        if (func(leftx, g) > func(leftx, f) && func(midx, g) > func(midx, f) && func(rightx, g) > func(rightx, f)) {
            // 区間全部で元の g より小さいならこの区間ですることはない
            return;
        }
        if (func(leftx, g) < func(leftx, f) && func(midx, g) < func(midx, f) && func(rightx, g) < func(rightx, f)) {
            // 区間全部で大きい値をとるなら入れ替え
            lines[k] = f;
            return;
        }

        // f と g の値がどこかで入れ替わるので
        if (func(midx, f) > func(midx, g)) {
            lines[k] = f;
            f = g;
            g = lines[k];
        }
        if (func(leftx, f) > func(leftx, g)) {
            _insert(f, 2 * k + 1, l, (l + r) >> 1);
        } else if (func(rightx, f) > func(rightx, g)) {
            _insert(f, 2 * k + 2, (l + r) >> 1, r);
        }
    }

    // [l, r)
    T query(G x) {
        int idx = lower_bound(xs.begin(), xs.end(), x) - xs.begin();
        return _query(0, 0, sz, idx);
    }
    T _query(int k, int l, int r, int idx) {
        // cerr << k << ' ' << l << ' ' << r << '\n';
        if (l + 1 == r) {
            return func(xs[l], lines[k]);
        }
        int mid = (l + r) >> 1;
        // [l, mid), [mid, right)
        T chx = (idx < mid ? _query(2 * k + 1, l, mid, idx) : _query(2 * k + 2, mid, r, idx));
        if (chx > func(xs[idx], lines[k])) return chx;
        else return func(xs[idx], lines[k]);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; ll c;
    cin >> n >> c;
    vll h(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    ConvexHullTrick<ll, ll> cht(n, h);
    vll dp(n, HIGHINF);
    dp[0] = 0;
    cht.insert(2 * h[0], -(h[0] * h[0]));
    for (int i = 1; i < n; i++) {
        ll minx = -cht.query(h[i]);
        // cout << minx << '\n';
        dp[i] = minx + h[i] * h[i] + c;
        cht.insert(2 * h[i], -(dp[i] + h[i] * h[i]));
    }
    // DEBUG_VLL(dp)
    cout << dp.back() << '\n';
    return 0;
}


Measured memory_bytes: 17736