// 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() {
  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;
}

Measured memory_bytes: 13548