#include <cassert>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<ll, ll>;

template<typename T,T id>
class LiChaoSegmentTree{

  struct Line{
    std::pair<T,T> coeffi;

    Line(std::pair<T,T> a):coeffi(a){}

    T value(T x){
      return coeffi.first*x+coeffi.second;
    }
  };

  struct Node{

    std::shared_ptr<Node> left,right;
    Line line;

    Node():line(std::pair<T,T>(0,id)),left(),right(){}

    Node(Line line_):line(line_),left(),right(){}
  };

  private:

  long long n,n0;
  std::vector<T> num;

  std::shared_ptr<Node> root;



  public:

  LiChaoSegmentTree(long long n_):n(n_),root(new Node()),num(std::vector<T>(n_,0)){
    for(ll i=1;i<n_;i++)num[i]=num[i-1]+1;

    n0=1;
    while(n0<n_)n0<<=1;
  }

  LiChaoSegmentTree(long long n_,const std::vector<T>& num_):n(n_),root(new Node()),num(num_){
    n0=1;
    while(n0<n_)n0<<=1;
  }

  void addline(std::pair<T,T> line_){
    Line f=Line(line_);
    std::shared_ptr<Node> now(root);
    long long l=0,r=n0;
    while(r-l>1){

      if(f.value(num[l])>=now->line.value(num[l])&&f.value(num[std::min(n,r)-1])>=now->line.value(num[std::min(n,r)-1])){
        return;
      }

      if(f.value(num[l]) < now->line.value(num[l])&&f.value(num[std::min(n,r)-1]) < now->line.value(num[std::min(n,r)-1])){
        now->line=f;
        return;
      }

      long long mid=l+(r-l)/2;

      if(n<=mid){
        if(now->line.value(num[n-1]) > f.value(num[n-1])){
          std::swap(now->line,f);
        }

        if(!now->left)now->left=std::make_shared<Node>();
        now=now->left;
        r=mid;
      }else{
        if(now->line.value(num[mid-1]) > f.value(num[mid-1])){
          std::swap(now->line,f);
        }

        if(now->line.value(num[l]) > f.value(num[l])){
          if(!now->left)now->left=std::make_shared<Node>();
          now=now->left;
          r=mid;
        }else{
          if(!now->right)now->right=std::make_shared<Node>();
          now=now->right;
          l=mid;
        }
      }
    }

    if(now->line.value(l) > f.value(l)){
      now->line=f;
      return;
    }
  }

  T query(T val){
    long long i=std::lower_bound(all(num),val)-num.begin();
    std::shared_ptr<Node> now(root);

    T ans=now->line.value(num[i]);

    long long l=0,r=n0;
    while(r-l>1){
      if(ans > now->line.value(num[i]))ans=now->line.value(num[i]);
      long long mid=l+(r-l)/2;

      if(i<mid){
        r=mid;
        if(!now->left)return ans;

        now=now->left;
      }else{
        l=mid;
        if(!now->right)return ans;

        now=now->right;
      }

    }

    if(now->line.value(num[i]) < ans)ans=now->line.value(num[i]);

    return ans;
  }
};

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  ll n,c;
  std::cin>>n>>c;

  std::vector<ll> h(n);
  rep(i,0,n)std::cin>>h[i];

  std::vector<ll> dp(n,0);

  LiChaoSegmentTree<ll,std::numeric_limits<ll>::max()> cht(1000100);

  cht.addline({-2*h[0],h[0]*h[0]});

  rep(i,1,n){
    dp[i]=cht.query(h[i])+h[i]*h[i]+c;
    cht.addline({-2*h[i],h[i]*h[i]+dp[i]});
  }

  std::cout<<dp[n-1]<<"\n";

  return 0;
}

Measured memory_bytes: 26880