#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

ll xs[1500000], p[1500000], q[1500000];
bool used[1500000];

struct LiChaoTree {
    int n;
    // ll *xs;
    // ll *p;
    // ll *q;
    // bool *used;

    void baseaddline(ll a, ll b, int k, int l, int r) {
        while (r - l > 0) {
            int m = (l + r) / 2;
            if (!used[k]) {
                p[k] = a;
                q[k] = b;
                used[k] = true;
                return;
            }

            ll lx = xs[l], mx = xs[m], rx = xs[r - 1];
            ll pk = p[k], qk = q[k];
            bool left = (a * lx + b < pk * lx + qk);
            bool mid = (a * mx + b < pk * mx + qk);
            bool right = (a * rx + b < pk * rx + qk);
            if (left && right) {
                p[k] = a;
                q[k] = b;
                return;
            }
            if (!left && !right) {
                return;
            }
            if (mid) {
                swap(p[k], a);
                swap(q[k], b);
            }
            if (left != mid) {
                k = 2 * k + 1;
                r = m;
            } else {
                k = 2 * k + 2;
                l = m;
            }
        }
    }

    ll basequery(int k, ll x) {
        k += n - 1;
        ll s = (used[k]) ? p[k] * x + q[k] : llmax;
        while (k > 0) {
            k = (k - 1) / 2;
            if (used[k]) {
                ll r = p[k] * x + q[k];
                s = min(s, r);
            }
        }
        return s;
    }

    LiChaoTree(vector<ll> ps) {
        int n_ = ps.size();
        n = 1;
        while (n < n_) {
            n *= 2;
        }
        // xs = new ll[2 * n];
        // p = new ll[2 * n];
        // q = new ll[2 * n];
        // used = new bool[2 * n];
        REP(i, 0, 2 * n) {
            used[i] = false;
        }
        REP(i, 0, n_) {
            xs[i] = ps[i];
        }
        REP(i, n_, n) {
            xs[i] = 1e7;
        }
    }

    void addline(ll a, ll b) {
        baseaddline(a, b, 0, 0, n);
    }

    void addsegmentline(ll a, ll b, int l, int r) {
        if (r == -1) {
            r = n;
        }
        ll l0 = l + n;
        ll r0 = r + n;
        ll s0 = l;
        ll t0 = r;
        ll sz = 1;
        while (l0 < r0) {
            if (r0 & 1) {
                r0--;
                t0 -= sz;
                baseaddline(a, b, r0 - 1, t0, t0 + sz);
            }
            if (l0 & 1) {
                baseaddline(a, b, l0 - 1, s0, s0 + sz);
                l0++;
                s0 += sz;
            }
            l0 /= 2;
            r0 /= 2;
            sz *= 2;
        }
    }

    ll query(int i) {
        return basequery(i, xs[i]);
    }
};

ll dp[200010];
vector<ll> h;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, C;
    cin >> N >> C;
    REP(i, 0, N) {
        ll hi;
        cin >> hi;
        h.push_back(hi);
    }
    LiChaoTree li(h);
    dp[0] = 0;
    li.addline(-2 * h[0], dp[0] + h[0] * h[0]);
    REP(i, 1, N) {
        ll mindat = li.query(i);
        dp[i] = mindat + h[i] * h[i] + C;
        li.addline(-2 * h[i], dp[i] + h[i] * h[i]);
    }
    // REP(i, 0, N) {
    //     cout << dp[i] << " ";
    // }
    // cout << endl;
    ll ans = dp[N - 1];
    cout << ans << endl;
}


Measured memory_bytes: 18392