/**
 * @brief ユーザ定義リテラル
 * @author えびちゃん
 */

#ifndef H_int_literals
#define H_int_literals

#include <cstddef>
#include <cstdint>

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

#endif  /* !defined(H_int_literals) */

/**
 * @brief ラムダ式の再帰
 * @author えびちゃん
 */

#ifndef H_make_fix_point
#define H_make_fix_point

#include <utility>

template <typename Fn>
class fix_point: Fn {
public:
  explicit constexpr fix_point(Fn&& f) noexcept: Fn(std::forward<Fn>(f)) {}

  template <typename... Args>
  constexpr decltype(auto) operator ()(Args&&... args) const {
    return Fn::operator ()(*this, std::forward<Args>(args)...);
  }
};

template <typename Fn>
static inline constexpr decltype(auto) make_fix_point(Fn&& f) noexcept {
  return fix_point<Fn>{std::forward<Fn>(f)};
}

#endif  /* !defined(H_make_fix_point) */

// ----------------------------------------------------------------
#include <cstddef>
#include <functional>
#include <limits>
#include <map>
#include <tuple>
#include <utility>

template <typename Tp>
class lower_envelope {
public:
  using size_type = size_t;
  using value_type = Tp;

private:
  using interval_type = std::pair<value_type, value_type>;
  using line_type = std::pair<value_type, value_type>;
  std::map<interval_type, line_type> M_lines;
  std::map<line_type, interval_type, std::greater<line_type>> M_intervals;
  static value_type const S_min = std::numeric_limits<value_type>::min();
  static value_type const S_max = std::numeric_limits<value_type>::max();

  static value_type S_divfloor(value_type x, value_type y) {
    value_type q = x / y;
    value_type r = x % y;
    if (r < 0) --q;
    return q;
  }

  static value_type S_divceil(value_type x, value_type y) {
    value_type q = x / y;
    value_type r = x % y;
    if (r > 0) ++q;
    return q;
  }

public:
  bool push(value_type const& a, value_type const& b) {
    // try to push y = ax+b; return true if it is actually pushed
    if (M_lines.empty()) {
      M_lines[interval_type(S_min, S_max)] = line_type(a, b);
      M_intervals[line_type(a, b)] = interval_type(S_min, S_max);
      return true;
    }

    auto it = M_intervals.lower_bound(line_type(a, S_min));
    value_type lb = S_min;
    value_type ub = S_max;

    auto it1 = it;  // next one
    if (it != M_intervals.end() && it->first.first == a) {
      if (it->first.second <= b) return false;
      M_lines.erase(it->second);
      it1 = M_intervals.erase(it);
    }

    auto it0 = M_intervals.end();  // previous one
    if (it != M_intervals.begin()) it0 = std::prev(it);

    if (it0 != M_intervals.end()) {
      value_type a0, b0;
      std::tie(a0, b0) = it0->first;
      lb = S_divceil(b-b0, -(a-a0));  // XXX this may cause overflow
    }
    if (it1 != M_intervals.end()) {
      value_type a1, b1;
      std::tie(a1, b1) = it1->first;
      ub = S_divfloor(b1-b, -(a1-a));  // XXX this may cause overflow
    }
    if (ub < lb) return false;

    if (it0 != M_intervals.end()) {
      while (lb <= it0->second.first) {
        M_lines.erase(it0->second);
        it0 = M_intervals.erase(it0);
        if (it0 == M_intervals.begin()) {
          it0 = M_intervals.end();
          break;
        }
        --it0;
        value_type a0, b0;
        std::tie(a0, b0) = it0->first;
        lb = S_divceil(b-b0, -(a-a0));
      }
    }

    while (it1 != M_intervals.end() && it1->second.second <= ub) {
      M_lines.erase(it1->second);
      it1 = M_intervals.erase(it1);
      value_type a1, b1;
      std::tie(a1, b1) = it1->first;
      ub = S_divfloor(b1-b, -(a1-a));
    }

    if (it0 != M_intervals.end()) {
      value_type a0, b0, l0, u0;
      std::tie(a0, b0) = it0->first;
      std::tie(l0, u0) = it0->second;
      it0->second.second = std::min(u0, lb-1);
      M_lines.erase(interval_type(l0, u0));
      M_lines[it0->second] = it0->first;
    }
    if (it1 != M_intervals.end()) {
      value_type a1, b1, l1, u1;
      std::tie(a1, b1) = it1->first;
      std::tie(l1, u1) = it1->second;
      it1->second.first = std::max(l1, ub+1);
      M_lines.erase(interval_type(l1, u1));
      M_lines[it1->second] = it1->first;
    }

    M_lines[interval_type(lb, ub)] = line_type(a, b);
    M_intervals[line_type(a, b)] = interval_type(lb, ub);

    return true;
  }

  value_type get(value_type const& x) {
    // return the minimum value at x
    value_type a, b;
    std::tie(a, b) = (--M_lines.upper_bound(interval_type(x, S_max)))->second;
    return a*x + b;
  }
};

template <typename Tp> Tp const lower_envelope<Tp>::S_min;
template <typename Tp> Tp const lower_envelope<Tp>::S_max;
// ----------------------------------------------------------------

#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

int main() {
  size_t n;
  intmax_t c;
  scanf("%zu %jd", &n, &c);

  std::vector<intmax_t> a(n);
  for (auto& ai: a) scanf("%jd", &ai);

  intmax_t const inf = 1e18;
  std::vector<intmax_t> dp(n, inf);

  auto f = [&](size_t l, size_t r) {
    return dp[l] + (a[l]-a[r]) * (a[l]-a[r]) + c;
  };

  auto induce = [&](size_t l, size_t m, size_t r) -> void {
    lower_envelope<intmax_t> le;
    for (size_t i = l; i < m; ++i) {
      le.push(-2*a[i], dp[i]+a[i]*a[i]);
    }
    for (size_t j = m; j < r; ++j) {
      intmax_t cur = le.get(a[j]) + a[j]*a[j] + c;
      dp[j] = std::min(dp[j], cur);
    }
  };

  auto solve = make_fix_point([&](auto& solve_, size_t l, size_t r) -> void {
      if (l+1 == r) {
        if (r < n) dp[r] = std::min(dp[r], f(l, r));
        return;
      }
      size_t m = (l+r) >> 1;
      solve_(l, m);
      induce(l, m, r);
      solve_(m, r);
  });

  dp[0] = 0;
  solve(0, n);

  printf("%jd\n", dp[n-1]);
}


Measured memory_bytes: 18944