#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

template<typename T>
class ConvecHullTrick {
private:
  // 直線群(配列)
  std::vector<std::pair<T, T>> lines;
  // 最小値(最大値)を求めるxが単調であるか
  bool isMonotonicX;
  // 最小/最大を判断する関数
  std::function<bool(T l, T r)> comp;

public:
  // コンストラクタ ( クエリが単調であった場合はflag = trueとする )
  ConvecHullTrick(bool flagX = false, std::function<bool(T l, T r)> compFunc = [](T l, T r) {return l >= r; })
    :isMonotonicX(flagX), comp(compFunc)  {
    lines.emplace_back(0, 0);
  };

  // 直線l1, l2, l3のうちl2が不必要であるかどうか
  bool check(std::pair<T, T> l1, std::pair<T, T> l2, std::pair<T, T> l3) {
    if (l1 < l3) std::swap(l1, l3);
    return (l3.second - l2.second) * (l2.first - l1.first) >= (l2.second - l1.second) * (l3.first - l2.first);
  }

  // 直線y=ax+bを追加する
  void add(T a, T b) {
    std::pair<T, T> line(a, b);
    while (lines.size() >= 2 && check(*(lines.end() - 2), lines.back(), line))
      lines.pop_back();
    lines.emplace_back(line);
  }

  // i番目の直線f_i(x)に対するxの時の値を返す
  T f(int i, T x) {
    return lines[i].first * x + lines[i].second;
  }

  // i番目の直線f_i(x)に対するxの時の値を返す
  T f(std::pair<T, T> line, T x) {
    return line.first * x + line.second;
  }

  // 直線群の中でxの時に最小(最大)となる値を返す
  T get(T x) {
    // 最小値(最大値)クエリにおけるxが単調
    if (isMonotonicX) {
      static int head = 0;
      while (lines.size() - head >= 2 && comp(f(head, x), f(head + 1, x)))
        ++head;
      return f(head, x);
    }
    else {
      int low = -1, high = lines.size() - 1;
      while (high - low > 1) {
        int mid = (high + low) / 2;
        (comp(f(mid, x), f(mid + 1, x)) ? low : high) = mid;
      }
      return f(high, x);
    }
  }
};

void solve() {
  ConvecHullTrick<i64> cht(true);
  int N;
  i64 C;
  cin >> N >> C;
  vi32 h(N);
  cin >> h;
  vi64 dp(N);
  cht.add(-2 * h[0], (i64) h[0] * h[0] + 0);
  reps(i, N - 1) {
    dp[i] = cht.get(h[i]) + C + (i64) h[i] * h[i];
    cht.add(-2 * h[i], (i64) h[i] * h[i] + dp[i]);
  }
  cout << dp[N - 1] << endl;
}


Measured memory_bytes: 8944