#include <bits/stdc++.h>

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

//傾きの単調性が必要なConvex Hull Trick
template <typename T>
struct ConvexHullTrickMonotone {
  const double eps = 1e-10;
  deque<pair<T, T>> line;

  bool isMinQuery;
  bool isMonotoneQuery;
  ConvexHullTrickMonotone(bool b = true, bool m = false) : isMinQuery(b), isMonotoneQuery(m){};
  bool check(pair<T, T> l1, pair<T, T> l2, pair<T, T> l3) {
    //whether line l2 is included in the convex hull
    if (isMinQuery && (((l1.second - l2.second) * (l2.first - l3.first) < (l2.second - l3.second) * (l1.first - l2.first)) ^ (l1.first > l2.first))) return true;
    if (!isMinQuery && (l1.second - l2.second) * (l2.first - l3.first) > (l2.second - l3.second) * (l1.first - l2.first)) return true;
    return false;
  }
  void add(T slope, T c) {
    //add a line : y = slope * x + c
    pair<T, T> now = {slope, c};
    while (line.size() >= 2) {
      int s = line.size();
      if (!check(line[s - 2], line[s - 1], now)) {
        line.pop_back();
      } else {
        break;
      }
    }
    line.push_back(now);
  }
  T getValue(T x) {
    //assert(line.size() > 0);
    if (line.size() == 0) return LINF * (-1 + 2 * isMinQuery);
    if (isMonotoneQuery) {
      while (isMinQuery && line.size() > 1 && line[0].first * x + line[0].second > line[1].first * x + line[1].second) {
        line.pop_front();
      }
      while (!isMinQuery && line.size() > 1 && line[0].first * x + line[0].second < line[1].first * x + line[1].second) {
        line.pop_front();
      }
      return line[0].first * x + line[0].second;
    } else {
      int lb = -1, ub = line.size() - 1;
      while (ub - lb > 1) {
        int mid = (ub + lb) / 2;
        //mid より後ろに最適な直線があるのか？
        if (isMinQuery && line[mid].first * x + line[mid].second > line[mid + 1].first * x + line[mid + 1].second) {
          lb = mid;
        } else if (!isMinQuery && line[mid].first * x + line[mid].second < line[mid + 1].first * x + line[mid + 1].second) {
          lb = mid;
        } else {
          ub = mid;
        }
      }
      return line[ub].first * x + line[ub].second;
    }
  }
};
class Solver {
 public:
  int n;
  LL c;
  vector<LL> h;
  vector<LL> dp;
  ConvexHullTrickMonotone<LL> cht;
  Solver(LL n) : n(n), h(n), dp(n), cht(true, true){};

  void solve() {
    cin >> c;
    for (int i = 0; i < n; ++i) {
      cin >> h[i];
    }
    //dp[j] = \min_{i=0~i-1} (dp[i]+(h[j]-h[i])^2+C)
    //      =  \min_{i=0~i-1} (dp[i]+h[i]^2-2*h[i]h[j])+C+h[j]^2
    dp[0] = 0;
    cht.add(-2 * h[0], dp[0] + h[0] * h[0]);
    for (int j = 1; j < n; ++j) {
      dp[j] = cht.getValue(h[j]) + c + h[j] * h[j];
      cht.add(-2 * h[j], dp[j] + h[j] * h[j]);
      DBG(cht.line)
    }
    cout << dp[n - 1] << endl;
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 5632