#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;


struct Frac {
  lint a, b;
  Frac(lint a = 0) : a(a), b(1) {}
  Frac(lint _a, lint _b) {
    assert(_b);
    lint d = __gcd(abs(_a), abs(_b));
    if (_b < 0) d = -d;
    a = _a / d;
    b = _b / d;
  }
  Frac operator+() const { return *this; }
  Frac operator-() const { Frac res(-a); res.b = b; return res; }
  explicit operator bool() const noexcept { return a; }
  bool operator!() const noexcept { return !(bool) *this; }
  Frac operator*(const Frac& r) const { return Frac(*this) *= r; }
  Frac operator/(const Frac& r) const { return Frac(*this) /= r; }
  Frac operator+(const Frac& r) const { return Frac(*this) += r; }
  Frac operator-(const Frac& r) const { return Frac(*this) -= r; }
  bool operator<(const Frac& r) const { return a * r.b < r.a * b; }
  bool operator>(const Frac& r) const { return r > *this; }
  bool operator<=(const Frac& r) const { return !(*this > r); }
  bool operator>=(const Frac& r) const { return !(*this < r); }
  bool operator==(const Frac& r) const { return a == r.a and b == r.b; }
  bool operator!=(const Frac& r) const { return !(*this == r); }
  Frac& operator*=(const Frac& r) { return *this = {a * r.a, b * r.b}; }
  Frac& operator/=(const Frac& r) { return *this = {a * r.b, b * r.a}; }
  Frac& operator+=(const Frac& r) { return *this = {a * r.b + r.a * b, b * r.b}; }
  Frac& operator-=(const Frac& r) { return *this += -r; }
  template<class Z> friend Frac operator*(Z l, const Frac& r) { return Frac(l) *= r; }
  template<class Z> friend Frac operator/(Z l, const Frac& r) { return Frac(l) /= r; }
  template<class Z> friend Frac operator+(Z l, const Frac& r) { return Frac(l) += r; }
  template<class Z> friend Frac operator-(Z l, const Frac& r) { return Frac(l) -= r; }
  friend ostream& operator<<(ostream& os, const Frac& r) { return os << r.a << " / " << r.b; }
  friend istream& operator>>(istream& is, Frac& r) { lint a, b; cin >> a >> b; r = {a, b}; return is; }
  template<class Z> friend bool operator==(Z l, const Frac& r) { return Frac(l) == r; }
  template<class Z> friend bool operator!=(Z l, const Frac& r) { return !(l == r); }
};

struct ConvexHullTrick {
  static constexpr lint inf = numeric_limits<lint>::max();
  static constexpr lint max_x = 2e6;
  struct Line {
    lint a, b;
    Frac x; // 右端
    bool operator<(const Line& r) const {
      if (a == inf and b == inf or r.a == inf and r.b == inf) return x < r.x;
      return a < r.a;
    }
  };
  set<Line> se;
  bool need(const Line& l, const Line& m, const Line& r) {
    return m.b * (r.a - l.a) > l.b * (r.a - m.a) + r.b * (m.a - l.a);
  }
  void add(lint a, lint b) {
    auto itr = se.find({a});
    if (itr != end(se)) {
      if (b <= itr->b) return;
      itr = se.erase(itr);
    } else {
      itr = se.lower_bound({a});
      if (itr != begin(se) and itr != end(se) and !need(*prev(itr), {a, b}, *itr)) return;
    }
    if (itr != end(se)) {
      while (next(itr) != end(se) and !need({a, b}, *itr, *next(itr))) {
        itr = se.erase(itr);
      }
    }
    if (itr != begin(se)) {
      while (prev(itr) != begin(se) and !need(*prev(itr, 2), *prev(itr), {a, b})) {
        se.erase(prev(itr));
      }
    }
    Frac x = max_x;
    if (itr != end(se)) {
      x = {-(itr->b - b), itr->a - a};
    }
    itr = se.emplace_hint(itr, Line{a, b, x});
    if (itr != begin(se)) {
      auto e = *prev(itr);
      se.erase(prev(itr));
      e.x = {-(b - e.b), a - e.a};
      se.insert(e);
    }
  }
  lint max(lint x) const {
    auto itr = se.lower_bound({inf, inf, x});
    return itr->a * x + itr->b;
  }
};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  lint c; cin >> c;
  V<lint> h(n); for (int i = 0; i < n; ++i) cin >> h[i];
  ConvexHullTrick cht;
  V<lint> dp(n, 1e18);
  for (int i = 0; i < n; ++i) {
    if (i == 0) {
      dp[i] = 0;
    } else {
      dp[i] = -cht.max(h[i]) + h[i] * h[i] + c;
    }
    cht.add(2 * h[i], -(dp[i] + h[i] * h[i]));
  }
  cout << dp.back() << '\n';
}

Measured memory_bytes: 19072