#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

ll gcd(ll a, ll b){
  if(b<a) swap(a, b);
  ll r = a % b;
  if(r==0) return b;
  while(r!=0) r = a % b, a = b, b = r;
  return a;
}

struct fraction{
  ll a, b;
  fraction(){};
  fraction(ll A, ll B){// A/B
    if(A==0) B = 1;
    else{
      if(A<=0&&B<0) A*=-1, B*=-1;
      ll g = gcd(abs(A), abs(B));
      A/=g, B/=g;
    }
    a = A, b = B;
  }
  bool operator == (fraction r) const{
    return (this->a==r.a && this->b==r.b);
  }

  bool operator < (fraction r) const {
    __int128_t left = (__int128_t)this->a*(__int128_t)r.b;
    __int128_t right = (__int128_t)r.a*(__int128_t)this->b;
    return left < right;
  }

  bool operator <= (fraction r) const{
    __int128_t left = (__int128_t)this->a*(__int128_t)r.b;
    __int128_t right = (__int128_t)r.a*(__int128_t)this->b;
    std::cout << (ll)left << " " << (ll)right << '\n';
    return left <= right;
  }
  bool operator > (fraction r) const{
    __int128_t left = (__int128_t)this->a*(__int128_t)r.b;
    __int128_t right = (__int128_t)r.a*(__int128_t)this->b;
    return left > right;
  }
  bool operator >= (fraction r) const{
    __int128_t left = (__int128_t)this->a*(__int128_t)r.b;
    __int128_t right = (__int128_t)r.a*(__int128_t)this->b;
    return left >= right;
  }

};
void print(fraction f){
  printf("(%lld / %lld)", f.a, f.b);
}
void println(fraction f){
  printf("(%lld / %lld)\n", f.a, f.b);
}

struct line{
  ll a, b;
  line(ll A, ll B):a(A), b(B){};
  fraction inter(line r){
    return fraction(b - r.b, r.a - a);
  }
};

template<typename T>
bool compar(T a, T b){
  return a < b;
}
struct CHT{
  typedef pair<fraction, line> pl;
  //傾きaの辺を追加する時、その周囲の「もう最小値を取らなくなった辺」を削除する
  // 傾き　-> 前の線との交点、直線
  map<ll, pl> mp;
  map<fraction, line> rev;

  void add(line l){
    if(mp.size()==0){
      mp.emplace(-l.a, pl(fraction(-1000000000000000000, 1), l));
      rev.emplace(fraction(-1000000000000000000, 1), l);
      return;
    }
    if(mp.find(-l.a)!=mp.end()){
      //同じ傾きのものが存在する場合
      auto itr = mp.find(-l.a);
      if((*itr).second.second.b<=l.b) return;

      fraction f = (*itr).second.first;
      itr++;
      mp.erase(-l.a);
      rev.erase(f);

      if(itr!=mp.end()){
        fraction tmp = (*itr).second.first;
        if(itr==mp.begin()){
          rev.erase(tmp);
          (*itr).second.first = fraction(-1000000000000000000, 1);
          rev.emplace(fraction(-1000000000000000000, 1), (*itr).second.second);
        }else{
          auto pre = itr;pre--;
          rev.erase(tmp);
          fraction nw = (*itr).second.second.inter((*pre).second.second);
          rev.emplace(nw, (*itr).second.second);
          (*itr).second.first = nw;
        }
      }
    }

    //挿入した時、前の直線との交点が次の直線の持つ値より大きい場合不要
    auto itr = mp.upper_bound(-l.a);
    if(itr!=mp.end()){
      fraction checkX = (*itr).second.first;
      auto pre = itr;
      if(l.inter((*--pre).second.second) > checkX) return;
    }

    if(itr!=mp.begin()){
      itr--;
      while(itr!=mp.begin()){
        auto pre = itr;pre--;
        fraction old = (*itr).second.first;
        fraction tmp = l.inter((*itr).second.second);
        if(tmp > old) break;
        rev.erase(old);
        mp.erase(itr);
        itr=pre;
      }
    }
    fraction nw = l.inter((*itr).second.second);
    mp.emplace(-l.a, pl(nw, l));
    rev.emplace(nw, l);
    itr = mp.find(-l.a);itr++;
    if(itr!=mp.end()){
      (*itr).second.first = (*itr).second.second.inter(l);
      fraction base = (*itr).second.first;itr++;
      while(itr!=mp.end()){
        if(base < (*itr).second.first) break;
        auto nxt = itr;nxt++;
        rev.erase((*itr).second.first);
        mp.erase(itr);
        itr = nxt;
      }
    }
  }
  line get(fraction f){
    auto itr = rev.lower_bound(f);
    return (*--itr).second;
  }
};

int main(int argc, char const *argv[]) {
  CHT ch;
  ll n, c;std::cin >> n >> c;
  vll h(n);
  re(i, n) scanf("%lld", &h[i]);

  ch.add(line(-2*h[0], h[0]*h[0]));

  for(int i=1;i<n;i++){
    line l = ch.get(fraction(h[i], 1));
    ll tmp = c + h[i]*h[i] + l.a*h[i] + l.b;
    ch.add(line(-2*h[i], h[i]*h[i] + tmp));
    if(i==n-1) std::cout << tmp << '\n';
  }
  return 0;
}


Measured memory_bytes: 35608