#include<bits/stdc++.h>
using namespace std;

// macros
#define int long long 
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define PB push_back
#define MP make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef long double ld;

// template functions
template < typename A, typename B >
ostream &operator << ( ostream& os, const pair< A, B > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "{";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}
template < typename A, typename B >
ostream &operator << ( ostream & os, const map< A, B > &v ) {
    os << "[";
    typename map< A, B >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " -> " << it -> second ;
    }
    return os << "]";
}
template<typename T>
T gcd(T a, T b) { if(a==0 or b==0) return a+b; return gcd(b, a%b) ; }
template<typename T>
T lcm(T a, T b) { if(a==0 or b==0) return 0; return a/gcd(a, b)*b; }

// random number generation
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// constants
const long double eps = LDBL_EPSILON;
const int inf = 1e15;
const int modn = 1e9+7;
const int maxn = 2e5+3;

struct pt {
    int x, y;

    pt() { x = 0, y = 0; }
    pt(int _x, int _y)  { x = _x, y = _y; }
    pt operator+(const pt& a) { return pt(x+a.x, y+a.y); }
    pt operator-(const pt& a) { return pt(x-a.x, y-a.y); }
    pt operator*(const int& a) { return pt(x*a, y*a); }
    pt operator/(const int& a) { return pt(x/a, y/a); }
    void operator+=(const pt& a) { x+=a.x, y+=a.y; }
    void operator-=(const pt& a) { x-=a.x, y-=a.y; }
    void operator*=(const int& a) { x*=a, y*=a; }
    void operator/=(const int& a) { x/=a, y/=a; }
};
ostream& operator << (ostream& os, const pt& p) {
    return os << "(" << p.x << ", " << p.y << ")";
}
int dot(pt a, pt b) { return a.x*b.x + a.y*b.y; }
int cross(pt a, pt b) { return a.x*b.y - b.x*a.y; }

struct lichaotree {
    int n;
    vector<pt> line;

    lichaotree() {}
    lichaotree(int _n) {
        n = _n;
        line.resize(4*n, pt(0, inf));
    }

    int f(pt p, int a) { return dot(p, pt(a, 1)); }

    void add_line(pt nw, int v, int l, int r) {
        int m = (l + r) / 2;
        bool lef = f(nw, l) < f(line[v], l);
        bool mid = f(nw, m) < f(line[v], m);
        if(mid) {
            swap(line[v], nw);
        }
        if(l==r) {
            return;
        } else if(lef != mid) {
            add_line(nw, 2*v+1, l, m);
        } else {
            add_line(nw, 2*v+2, m+1, r);
        }
    }

    int get(int x, int v, int l, int r) {
        int m = (l + r) / 2;
        if(l==r) {
            return f(line[v], x);
        } else if(x <= m) {
            return min(f(line[v], x), get(x, 2*v+1, l, m));
        } else {
            return min(f(line[v], x), get(x, 2*v+2, m+1, r));
        }
    }

    void add_line(pt nw) {
        add_line(nw, 0, 0, n-1);
    }
    int get(int x) {
        return get(x, 0, 0, n-1);
    }
};

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
    int n, c;
    cin>>n>>c;
    vi h(n);
    for(int i=0; i<n; i++) {
        cin>>h[i];
    }
    vi dp(n);
    lichaotree t1(1e6+1);
    t1.add_line(pt(-2*h[0], h[0]*h[0] + c));
    for(int i=1; i<n; i++) {
        dp[i] = h[i]*h[i] + t1.get(h[i]);
        t1.add_line(pt(-2*h[i], dp[i] + h[i]*h[i] + c));
    }
    cout << dp[n-1] << "\n";
    return 0;
}



Measured memory_bytes: 65920