#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


struct AffineMonoidAct {
  using T = pair<lint, lint>;
  using U = struct { lint a, b; };
  static void ap(const U& f, T& x) { if (f.a != id().a or f.b != id().b) x.first = f.a * x.second + f.b; }
  static void cp(const U& g, U& f) { if (g.a != id().a or g.b != id().b) f = g; }
  static constexpr U id() { return {0, (lint) 9e18}; }
};

template<class MonoidAct> struct SegmentTree {
  using M = MonoidAct;
  using T = typename M::T;
  using U = typename M::U;

  const int n;

  SegmentTree(int n, const T& a) :
    n(n), val(n, a), laz(n, M::id()) {}
  template<class Itr> SegmentTree(Itr first, Itr last) :
    n(distance(first, last)), val(first, last), laz(n, M::id()) {}

  void push() {
    for (int i = 1; i < n; ++i) push(i);
  }

  T get(int i) {
    assert(0 <= i and i < n);
    for (int h = __lg(i += n); h > 0; --h) {
      push(i >> h);
    }
    return val[i - n];
  }

  void set(int l, int r, const U& f) {
    l = max(l, 0), r = min(r, n);
    if (l >= r) return;
    push(l, r);
    for (int i = l + n, j = r + n; i < j; i >>= 1, j >>= 1) {
      if (i & 1) ap(f, i++);
      if (j & 1) ap(f, --j);
    }
  }
  void set(int i, const T& a) {
    assert(0 <= i and i < n);
    for (int h = __lg(i += n); h > 0; --h) {
      push(i >> h);
    }
    val[i - n] = a;
  }

private:
  V<T> val;
  V<U> laz;

  void ap(const U& f, int i) {
    if (i < n) M::cp(f, laz[i]);
    else M::ap(f, val[i - n]);
  }

  void push(int i) {
    ap(laz[i], 2 * i);
    ap(laz[i], 2 * i + 1);
    laz[i] = M::id();
  }
  void push(int l, int r) {
    for (int hl = __lg(l + n), hr = __lg(r - 1 + n); hr > 0; --hl, --hr) {
      int al = l + n >> hl, ar = r - 1 + n >> hr;
      if (al < n) push(al);
      if (ar != al) push(ar);
    }
  }
};

using ST = SegmentTree<AffineMonoidAct>;

int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n; cin >> n;
  lint c; cin >> c;
  V<lint> h(n);
  V< pair<lint, lint> > v(n);
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
    v[i] = {9e18, h[i]};
  }
  ST st(begin(v), end(v));
  auto add = [&](lint a, lint b) -> void {
    auto search = [&]() -> int {
      int ok = 0, ng = n;
      while (ng - ok > 1) {
        int mid = ok + ng >> 1;
        if (mid == 0 or st.get(mid).first - st.get(mid - 1).first >= a * (h[mid] - h[mid - 1])) ok = mid;
        else ng = mid;
      }
      return ok;
    };
    int i = search();
    if (a * h[i] + b >= st.get(i).first) return;
    auto search_l = [&]() -> int {
      int ng = -1, ok = i;
      while (ok - ng > 1) {
        int mid = ng + ok >> 1;
        if (mid >= 0 and a * h[mid] + b < st.get(mid).first) ok = mid;
        else ng = mid;
      }
      return ok;
    };
    auto search_r = [&]() -> int {
      int ok = i, ng = n;
      while (ng - ok > 1) {
        int mid = ok + ng >> 1;
        if (mid < n and a * h[mid] + b < st.get(mid).first) ok = mid;
        else ng = mid;
      }
      return ng;
    };
    int l = search_l(), r = search_r();
    st.set(l, r, {a, b});
  };
  V<lint> dp(n, 9e18);
  dp[0] = 0;
  add(-2 * h[0], h[0] * h[0]);
  for (int i = 1; i < n; ++i) {
    dp[i] = st.get(i).first + h[i] * h[i] + c;
    add(-2 * h[i], dp[i] + h[i] * h[i]);
  }
  cout << dp.back() << '\n';
}

Measured memory_bytes: 14720