#include<bits/stdc++.h>

using namespace std;

#define pb push_back

const int N = 2e5 + 5;
const long long inf = 1e18 + 123;
int n, h[N];
long long c, dp[N];

struct ConvexHull {
    vector<long long> A, B;
    int iA = 0;
    bool bad (int l1, int l2, int l3) { return (B[l3] - B[l1]) * (A[l1] - A[l2]) < (B[l2] - B[l1]) * (A[l1] - A[l3]); }
    void add (long long a, long long b) {
        A.pb(a); B.pb(b);
        while (A.size() >= 3 && bad(A.size() - 3, A.size() - 2, A.size() - 1) ) A.erase(A.end() - 2), B.erase(B.end() - 2);
    }
    long long val (int x, int id) { return A[id] * x + B[id]; }
    long long solve (int x) {
        iA = min(iA, (int)A.size() - 1);
        while (iA + 1 < A.size() ) {
            if (val(x, iA) <= val(x, iA + 1) ) break ;
            ++iA;
        }
        return val(x, iA);
    }
} convexHull;

int main () {
    scanf("%d %lld", &n, &c);

    for (int i = 1; i <= n; ++i) scanf("%d", h + i);

    for (int i = 2; i <= n; ++i) {
        convexHull.add(-2 * h[i - 1], 1LL * h[i - 1] * h[i - 1] + dp[i - 1]);
        dp[i] = 1LL * h[i] * h[i] + c + convexHull.solve(h[i]);
    }

    cout << dp[n];

    return 0;
}
