#ifndef LOCAL
#pragma GCC optimize ("O3")
#endif
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define mor > muu & operator << (
#define R22(r) sim > typename \
  enable_if<1 r sizeof dud<c>(0), muu&>::type operator<<(c g) {
sim > struct rge { c b, e; };
sim > rge<c> range(c h, c n) { return {h, n}; }
sim > auto dud(c* r) -> decltype(cerr << *r);
sim > char dud(...);
struct muu {
#ifdef LOCAL
stringstream a;
~muu() { cerr << a.str() << endl; }
R22(<) a << boolalpha << g; ris; }
R22(==) ris << range(begin(g), end(g)); }
sim, class b mor pair < b, c > r) { ris << "(" << r.first << ", " << r.second << ")"; }
sim mor rge<c> u) {
  a << "[";
  for (c i = u.b; i != u.e; ++i)
    *this << ", " + 2 * (i == u.b) << *i;
  ris << "]";
}
#else
sim mor const c&) { ris; }
#endif
muu & operator()() { ris; }
};
#define imie(r...) "[" #r ": " << (r) << "] "
#define imask(r...) "[" #r ": " << bitset<8 * sizeof(r)>(r) << "] "
#define arr(a, i) "[" #a imie(i) ": " << a[i] << "] "
#define arr2(a, i, j) "[" #a imie(i) imie(j) ": " << a[i][j] << "] "
#define debug (muu() << __FUNCTION__ << "#" << __LINE__ << ": ")

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ull> int128;

int128 operator +(int128 a, int128 b) {
	return int128{a.first + b.first + (a.second + b.second < a.second),
			a.second + b.second};
}
int128 operator -(int128 a, int128 b) {
	return int128{a.first - b.first - (a.second < b.second),
			a.second - b.second};
}

int128 mul(ll one, ll two) { // tested, works for any arguments
	const int K = 32;
	ll a = one >> K; // [-2^31, 2^31)
	ull b = one - (a << K); // [0, 2^32)
	ll c = two >> K;
	ull d = two - (c << K);
	int128 ans{a * c, b * d};
	for(int rep = 0; rep < 2; ++rep) {
		ll x = rep ? a * d : b * c;
		ans.first += x >> K;
		x -= (x >> K) << K;
		assert(0 <= x && x < (1LL << K));
		ans = ans + int128{0, (ull) x << K}; // works even without casting
	}
	return ans;
}

bool nonNegative(int128 x) {
    return x.first >= 0;
}

struct linie {
    vector <pair <long long, long long>> T;
    int poz = 0;
    
    void insert(long long a, long long b) {
        int sz = T.size();
        while (sz - poz > 1) {
            if (!nonNegative(mul(b - T[sz - 2].second, T[sz - 2].first - T[sz - 1].first) - 
                 mul(T[sz - 1].second - T[sz - 2].second, T[sz - 2].first - a))) {
                T.pop_back();
                sz--;
            }
            else break;
        }
        T.push_back({a, b});
    }
    
    long long query(int h) {
        long long war = 1e18;
        int sz = T.size();
        if (poz < sz) war = T[poz].first * h + T[poz].second;
        while (poz + 1 < sz) {
            long long nwar = T[poz + 1].first * h + T[poz + 1].second;
            if (nwar <= war) {
                poz++;
                war = nwar;
            }
            else break; 
        }
        return war;
    }
};

const int N = 2e5 + 7;
long long C;
int h[N];
int n;
long long dp[N];

int main() {
    scanf("%d %lld", &n, &C);
    for (int i = 1; i <= n; ++i) scanf("%d", h + i);
    
    linie X;
    
    for (int i = 1; i <= n; ++i) {
        if (i == 1) dp[i] = 0;
        else {
            dp[i] = X.query(h[i]) + C + 1ll * h[i] * h[i];
        }
        
        X.insert(-2 * h[i], dp[i] + 1ll * h[i] * h[i]);
    }
    printf("%lld\n", dp[n]);
    return 0;
}


Measured memory_bytes: 8304