#include<bits/stdc++.h>
#define For(i, a, b)  for(int i = a, _b = b; i <= _b; ++i)
#define Ford(i, a, b) for(int i = a, _b = b; i >= _b; --i)
#define FileName      "test"
#define ll            long long
#define ld            long double
#define ull           unsigned long long
#define Print(x)      cerr << #x << "is " << x << '\n';
#define pb            push_back
#define X             first
#define Y             second
//#define Karma

using namespace std;

template<typename T> inline void Cin(T &x)
{
    char c;
    T sign = 1;
    x = 0;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        if (c == '-') sign = -1;
    for (; c >= '0' && c <= '9'; c = getchar())
        x = x * 10 + c - '0';
    x *= sign;
}
template <typename T> inline void Out(T x) {if(x > 9) Out(x / 10); putchar(x % 10 + '0');}
template <typename T> inline void Cout(T x, char c) {if(x < 0) putchar('-'); x = abs(x); Out(x); putchar(c);}
template <typename T, typename... Args> inline void Cin(T& a, Args&... args) {Cin(a);Cin(args...);}
template <typename T, typename... Args> inline void Cout(T a, char c, Args... args) {Cout(a, c);Cout(args...);}

typedef pair<int, int> pii;
typedef pair<ll, int> plli;
const int N = 1e6 + 7;
const ll Cmax = 1e18 + 7;

int n;
ll C, h, f;

struct line
{
    ll a, b;
    line (ll a = 0, ll b = 0): a(a), b(b) {}
    ll GetVal(ll x) {return a * x + b;}
};

struct TSegment
{
    int l, r, mid;
    line cur;
    TSegment* left;
    TSegment* right;

    TSegment (int l = 0, int r = 0): l(l), r(r)
    {
        mid = (l + r) >> 1;
        cur = line();
        if(l == r)
        {
            left = right = NULL;
            return;
        }
        left = new TSegment(l, mid);
        right = new TSegment(mid + 1, r);
    }

    void Update(int x, int y, line val)
    {
        if(l > y || r < x) return;
        if(x <= l && r <= y)
        {
            ll lcur = cur.GetVal(l);
            ll rcur = cur.GetVal(r);
            ll lval = val.GetVal(l);
            ll rval = val.GetVal(r);
            if(lcur >= lval && rcur >= rval) {cur = val; return;}
            if(lcur <= lval && rcur <= rval) return;
            ll mval = val.GetVal(mid);
            ll mcur = cur.GetVal(mid);
            if(lcur >= lval && mcur >= mval)
            {
                right -> Update(x, y, cur);
                cur = val;
                return;
            }
            if(lcur <= lval && mcur <= mval)
            {
                right -> Update(x, y, val);
                return;
            }
            if(mcur >= mval && rcur >= rval)
            {
                left -> Update(x, y, cur);
                cur = val;
                return;
            }
            if(mcur <= mval && rcur <= rval)
            {
                left -> Update(x, y, val);
                return;
            }
        }
        left -> Update(x, y, val);
        right -> Update(x, y, val);
    }

    ll Query(int x)
    {
        if(l > x || r < x) return Cmax;
        ll res = cur.GetVal(x);
        if(l == r) return res;
        res = min(res, left -> Query(x));
        res = min(res, right -> Query(x));
        return res;
    }
};

void Enter()
{
     Cin(n, C);
     TSegment Min = TSegment(1, int(1e6));
     For(i, 1, n)
     {
         Cin(h);
         if(i > 1) f = Min.Query(h) + C + h * h;
         else f = 0;
         Min.Update(1, int(1e6), {-2ll * h, f + h * h});
     }
     cout << f;
}

void Solve()
{

}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef Karma
    freopen(FileName".inp", "r", stdin);
    freopen(FileName".out", "w", stdout);
#endif // Karma

    Enter();
    Solve();

    return 0;
}


Measured memory_bytes: 127360