#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;
template <typename T>
struct ConvexHullTrick {
  const double eps = 1e-10;
  const double Inf = 1e20;
  map<T, T> line;
  map<double, T> boundary;
  map<T, double> inv;
  bool isMinQuery;
  using Iter = decltype(line.begin());
  ConvexHullTrick(bool b = true) : isMinQuery(b){};

  void add(T slope, T c) {
    if (contains(line, slope) && c > at(line, slope)->first + eps) {
    } else {
      auto it = line.begin();
      if (contains(line, slope)) {
        it = at(line, slope);
        it->second = c;
      } else {
        line[slope] = c;
        it = at(line, slope);
      }
      DBG(*it, line, boundary, inv)
      if (0) {  //it == line.begin() || next(it) == line.end()) {
        setBoundary(at(line, slope)->first);
        if (next(it) != line.end()) setBoundary(next(it)->first);
        //if (it != line.begin()) setBoundary(prev(at(line, slope))->first);
      } else {
        auto itp = it;
        if (it != line.begin()) itp = prev(itp);
        auto itn = it;
        if (next(it) != line.end()) itn = next(itn);
        if (it != line.begin() && next(it) != line.end() && !check(*itp, *it, *itn)) {
          line.erase(it);
        }
        while (itp != line.begin()) {
          auto itpp = prev(itp);
          if (!check(*itpp, *itp, *it)) {
            itp--;
          } else {
            break;
          }
        }
        while (next(itn) != line.end()) {
          auto itnn = next(itn);
          if (!check(*it, *itn, *itnn)) {
            itn++;
          } else {
            break;
          }
        }
        auto lb = itp->first;
        auto ub = itn->first;
        DBG(lb, ub)
        //line.erase(next(itp), it);
        //line.erase(next(at(line, slope)), at(line, ub));
        eraseLines(next(itp), it);
        DBG(lb, ub)
        eraseLines(next(at(line, slope)), at(line, ub));
        DBG(lb, ub)
        setBoundary(at(line, slope)->first);
        setBoundary(at(line, ub)->first);
      }
    }
  }
  T getValue(T x) {
    assert(line.size() > 0);
    auto it = at(boundary, (double)x);
    return it->second * x + at(line, it->second)->second;
  }
  bool check(pair<T, T> l1, pair<T, T> l2, pair<T, T> l3) {
    //return if 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)) 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 eraseLines(Iter it, Iter it2) {
    DBG(*it, *it2, inv)
    for (auto now = it; now != line.end() && *now < *it2; ++now) {
      DBG(*now)
      boundary.erase(at(boundary, at(inv, now->first)->second));
      inv.erase(at(inv, now->first));
    }
    if (*it < *it2) line.erase(it, it2);
  }
  template <typename U, typename V>
  auto at(map<U, V> &mp, U key) {
    return mp.lower_bound(key - min<T>(eps, abs(key) * eps));
  }
  template <typename U, typename V>
  bool contains(map<U, V> &mp, U key) {
    double diff = abs(at(mp, key)->first - key);
    return diff < eps || abs(diff / key) < eps;
  }
  template <typename U, typename V>
  void setValue(map<U, V> &mp, U key, V val) {
    if (contains(mp, key)) {
      at(mp, key)->second = val;
    } else {
      mp[key] = val;
    }
  }
  void setBoundary(T x) {
    DBG(x)
    if (boundary.size() == 0) {
      boundary[Inf] = x;
      inv[x] = Inf;
    } else {
      if (at(line, x) == line.begin()) {
        DBG(x)
        if (contains(inv, x)) {
          boundary.erase(at(boundary, at(inv, x)->second));
        }
        setValue(inv, x, Inf);
        setValue(boundary, Inf, x);
      } else {
        auto c = at(line, x), n = prev(c);
        DBG(*c, *n)
        double p = (double)(n->second - c->second) / (c->first - n->first);
        DBG(boundary, inv)
        if (contains(inv, x) && at(boundary, at(inv, x)->second)->second == x) {
          boundary.erase(at(boundary, at(inv, x)->second));
        }
        setValue(inv, x, p);
        setValue(boundary, p, x);
      }
    }
  }
};
class Solver {
 public:
  int n;
  LL c;
  vector<LL> h;
  vector<LL> dp;
  ConvexHullTrick<LL> cht;
  Solver(LL n) : n(n), h(n), dp(n){};

  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]);
    DBG(cht.boundary)
    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)
      DBG(cht.boundary)
    }
    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: 40832