#include <iostream>
#include <fstream>
#include <cstring>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <random>
#include <complex>
#include <chrono>
#include <assert.h>

using namespace std;

//ifstream fin("input.in");
//ofstream fout("output.out");

typedef long long LL;
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const long long INF64 = 3e18 + 1;
const int N = 200555;
const int AMAX = 205;
const int LIM = 1000000000;

//typedef __uint128_t u128;

const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const char invdir[]{'L', 'U', 'R', 'D'};
const char dir[]{'R', 'D', 'L', 'U'};

#define all(a) (a).begin(), (a).end()
#define forn(i,a,b) for (int i = a; i <= b; i++)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define rc(s) return cout<<s,0
#define pi pair <int, int>

struct line {
    // Panta si termenul liber
    long long m, c;
    // Evaluam linia la coordonata x
    long long eval(long long x) { return m * x + c; }
    // Punctul de intersectie intre doua linii
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};

void solve() {

    // Convex hull:
    deque<line> dq;

    int n;
    LL C;
    cin >> n >> C;

    vector<long long> dp(n + 1, 0);
    vector<long long> h(n + 1, 0);
    for(int i = 1; i <= n; ++i){
        cin >> h[i];
    }

    dq.push_front({-2*h[1], h[1]*h[1]});

    for (int j = 2; j <= n; j++) {
        // Coordonatele care le vom intreba sunt strict crescatoare (h_j)
        // De aceea putem sa stergem liniile pana gasim linia care
        // e curespunzatoare coordonatei h_j

        // Atata timp cat linia cea mai din stanga nu este minima,
        // o stergem.
        while (dq.size() >= 2 && dq.back().eval(h[j]) >= dq[dq.size() - 2].eval(h[j]))
            dq.pop_back();

        // Acum linia cea mai din stanga e minima
        // Adaugam h[j]*h[j] pentru a finisa patratul (h_i + h_j)^2
        // Plus constanta C
        dp[j] = dq.back().eval(h[j]) + (h[j]*h[j] + C);


        // Adaugam o linie noua:
        // Adaugam h[j]*h[j] pentru a incepe patratul (h_i + h_j)^2
        line cur = {-2*h[j], dp[j] + h[j]*h[j]};

        // Admitem o linie la multime:
        // Explicatie:
        // Cat timp punctul de intersectie intre linia noua si linia
        // cea mai din dreapta este mai la stanga decat ultimul punct de
        // intersectie atunci ultima linie devine inutila si o inlaturam.
        while (dq.size() >= 2 && cur.intersectX(dq[0]) <= dq[0].intersectX(dq[1]))
            dq.pop_front();
        dq.push_front(cur);

        /*
        cout << "Lines: \n";
        for(auto el: dq){
            cout << el.m << " " << el.c << "\n";
        }
         */
    }
    /*
    for(int i = 1; i <= n; ++i)
        cout << dp[i] << " ";
    cout << "\n";
     */

    cout << dp[n] << "\n";

    // (h_i - h_j)^2 + C = h_i^2 - 2h_i h_j + h_j^2 + C

    // Pentru fiecare i < j
    // min( (dp[i] + h_i^2) - 2 h_i h_j)

    // min_i( a_i x + b_i ) pe coordonata x = h_j

    // Hint: Convex hull trick

    // Unde a_i = - 2 h_i, b_i = dp[i] + h_i^2
}

int main() {
    //std::ios_base::sync_with_stdio(0);
    //cin.tie(0);
    int T = 1;

    //cin >> T;

    int i = 1;
    while(T--){
        solve();
        i++;
    }


    return 0;
}



Measured memory_bytes: 5504