// Author: Tyler Wang

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdlib>
#include <deque>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>

using namespace std;

template <typename T, int Dim = 2>
struct point;

template <typename T>
struct point<T, 2> {
  T x, y;

  constexpr point(const T& _x = T(), const T& _y = T()) : x(_x), y(_y) {}

  constexpr point& operator+=(const point& other) {
    x += other.x;
    y += other.y;
    return *this;
  }

  constexpr point& operator-=(const point& other) {
    x -= other.x;
    y -= other.y;
    return *this;
  }

  constexpr point& operator*=(const T& val) {
    x *= val;
    y *= val;
    return *this;
  }

  constexpr point& operator/=(const T& val) {
    x /= val;
    y /= val;
    return *this;
  }

  friend constexpr point operator+(const point& p) { return p; }

  friend constexpr point operator-(const point& p) { return point(-p.x, -p.y); }

  friend constexpr point operator+(const point& lhs, const point& rhs) {
    return point(lhs.x + rhs.x, lhs.y + rhs.y);
  }

  friend constexpr point operator-(const point& lhs, const point& rhs) {
    return point(lhs.x - rhs.x, lhs.y - rhs.y);
  }

  friend constexpr point operator*(const point& lhs, const T& val) {
    return point(lhs.x * val, lhs.y * val);
  }

  friend constexpr point operator*(const T& val, const point& rhs) {
    return point(val * rhs.x, val * rhs.y);
  }

  friend constexpr point operator/(const point& lhs, const T& val) {
    return point(lhs.x / val, lhs.y / val);
  }

  friend constexpr bool operator==(const point& lhs, const point& rhs) {
    return lhs.x == rhs.x && lhs.y == rhs.y;
  }

  friend constexpr bool operator!=(const point& lhs, const point& rhs) {
    return !(lhs == rhs);
  }

  friend constexpr bool operator<(const point& lhs, const point& rhs) {
    return lhs.x != rhs.x ? lhs.x < rhs.x : lhs.y < rhs.y;
  }

  friend std::ostream& operator<<(std::ostream& os, const point& p) {
    return os << '(' << p.x << ',' << p.y << ')';
  }

  friend constexpr T norm(const point& p) { return p.x * p.x + p.y * p.y; }

  friend constexpr T dot(const point& lhs, const point& rhs) {
    return lhs.x * rhs.x + lhs.y * rhs.y;
  }

  friend constexpr T cross(const point& lhs, const point& rhs) {
    return lhs.x * rhs.y - lhs.y * rhs.x;
  }
};

int main_accepted() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.precision(12);
  std::cerr.precision(12);
  std::mt19937 rng((std::uint_fast32_t)std::chrono::high_resolution_clock::now()
                       .time_since_epoch()
                       .count());
  int n;
  long long c;
  cin >> n >> c;
  vector<long long> h(n);
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
  }
  // dp[i] = dp[j] + (hi - hj) ^ 2 + c
  //       = -2 hj * hi + (dp[j] + hj ^ 2) + (hi ^ 2 + c)
  vector<long long> dp(n);
  vector<point<__int128>> hull = {{-2 * h[0], h[0] * h[0]}};
  for (int i = 1, j = 0, k = 1; i < n; ++i) {
    point<__int128> p(h[i], 1);
    while (j + 1 < k && dot(hull[j], p) >= dot(hull[j + 1], p)) {
      ++j;
    }
    dp[i] = (long long)dot(hull[j], p) + h[i] * h[i] + c;
    p = point<__int128>(-2 * h[i], dp[i] + h[i] * h[i]);
    while (k - j >= 2 &&
           cross(hull[k - 1] - hull[k - 2], p - hull[k - 2]) >= 0) {
      hull.pop_back();
      --k;
    }
    hull.push_back(p);
    ++k;
  }
  cout << dp[n - 1] << '\n';
  return 0;
}

template <typename T>
class upper_hull {
 public:
  upper_hull() = default;

  upper_hull(std::vector<point<T, 2>> points) {
    std::sort(points.begin(), points.end());
    for (const point<T, 2>& p : points) {
      while ((int)hull_.size() >= 2 &&
             cross(hull_.back() - *prev(hull_.end(), 2),
                   p - *prev(hull_.end(), 2)) >= 0) {
        hull_.pop_back();
      }
      hull_.push_back(p);
    }
  }

  void push_back(const point<T, 2>& p) {
    while ((int)hull_.size() >= 2 && cross(hull_.back() - *prev(hull_.end(), 2),
                                           p - *prev(hull_.end(), 2)) >= 0) {
      hull_.pop_back();
    }
    hull_.push_back(p);
  }

  void emplace_back(const T& x, const T& y) { push_back(point<T, 2>(x, y)); }

  T max_dot(const point<T, 2>& p) {
    while ((int)hull_.size() >= 2 && dot(hull_[0], p) <= dot(hull_[1], p)) {
      hull_.pop_front();
    }
    return dot(hull_[0], p);
  }

  T max_dot(const T& x, const T& y) { return max_dot(point<T, 2>(x, y)); }

 private:
  std::deque<point<T, 2>> hull_;
};

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.precision(12);
  std::cerr.precision(12);
  std::mt19937 rng((std::uint_fast32_t)std::chrono::high_resolution_clock::now()
                       .time_since_epoch()
                       .count());
  int n;
  long long c;
  cin >> n >> c;
  vector<long long> h(n);
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
  }
  // dp[i] = dp[j] + (hi - hj) ^ 2 + c
  //       = -2 hj * hi + (dp[j] + hj ^ 2) + (hi ^ 2 + c)
  vector<long long> dp(n);
  upper_hull<__int128> hull;
  hull.emplace_back(-2 * h[0], h[0] * h[0]);
  for (int i = 1; i < n; ++i) {
    dp[i] = (long long)-hull.max_dot(-h[i], -1) + h[i] * h[i] + c;
    hull.emplace_back(-2 * h[i], dp[i] + h[i] * h[i]);
  }
  cout << dp[n - 1] << '\n';
  return 0;
}

Measured memory_bytes: 10852