/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T, bool isMin>
struct LiChao {

    int N;
    static constexpr T INF = numeric_limits<T>::max();
    struct Line {
        T a, b;
        Line(T a, T b): a(a), b(b){}
        T get(T x){ return a*x + b;}
    };
    vector<T> pos;
    vector<Line> dat;

    LiChao(int n) {
      pos.resize(n);
      for(int i=0; i<n; i++) pos[i] = i;
      init(n);
    }
    LiChao(const vector<T> &pos):pos(pos){init(pos.size());}

    void init(int n) {
      N=1;
      while(N<n) N<<=1;
      while((int)pos.size() < N) {
        pos.emplace_back(T(pos.back())+1);
      }
      dat.resize(2*N, Line(0, -INF/4));
    }

    // Add ax + b
    void addLine(T a, T b) {
      if (isMin) a = -a, b = -b;
      Line x = Line(a, b);
      update(1, 0, N-1, x);
    }

    void update(int k, int l, int r, Line &x) {
      T lb = pos[l], ub = pos[r];
      if (dat[k].get(lb) <= x.get(lb) && dat[k].get(ub) <= x.get(lb)) {
        dat[k] = x;
        return;
      }
      if (dat[k].get(lb) >= x.get(lb) && dat[k].get(ub) >= x.get(ub)) {
        return;
      }
      int med = (l + r) / 2;
      if (dat[k].get(pos[med]) < x.get(pos[med])) swap(dat[k], x);
      if (dat[k].get(lb) <= x.get(lb)) {
        update(k * 2, l, med, x);
      } else {
        update(k * 2 + 1, med + 1, r, x);
      }
    }

    T query(T x) {
      auto t = distance(pos.begin(), lower_bound(pos.begin(), pos.end(), x));
      if (isMin) {
        return -query(1, 0, N-1, t, x);
      } else {
        return query(1, 0, N-1, t, x);
      }
    }

    T query(int k, int l, int r, int t, T x) {
      T ret = dat[k].get(x);
      if (l==r) return ret;
      int c = (l+r)/2;
      if (t <= c) {
        return max(ret, query(k*2, l, c, t, x));
      } else {
        return max(ret, query(k*2+1, c+1, r, t, x));
      }
    }

};

class ZFrog3 {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; ll c; cin >> n >> c;
      vector<ll> h(n);
      rep(i, n) {
        cin >> h[i];
      }
      LiChao<ll, true> seg(h);
      vector<ll> dp(n);
      rep(i, n-1) {
        seg.addLine(-2*h[i], dp[i]+h[i]*h[i]);
        dp[i+1] = seg.query(h[i+1]) + c + h[i+1]*h[i+1];
      }
      cout << dp[n-1] << endl;
    }
};

signed main() {
  ZFrog3 solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 14584