#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;

ll n,c;
vector<ll> h;
vector<p> lines;
vector<ll> dp;

bool check(p p1, p p2, p p3){
  return (p2.second-p1.second)*(p3.first-p2.first)>(p3.second-p2.second)*(p2.first-p1.first);
}

ll get_y(p line, ll x){
  return line.first*x+line.second;
}

void add(p line){
  if(lines.size()>=2){
    ll t = lines.size()-1;
    while(t-1>=0&&!check(lines[t-1],lines[t],line)){
      lines.pop_back();
      t--;
    }
  }
  lines.push_back(line);
}

ll query(ll x){
  ll l = -1, r = lines.size()-1, mid;
  while(r-l>1){
    mid = (l+r)/2;
    if(get_y(lines[mid],x)>=get_y(lines[mid+1],x)){
      l = mid;
    }else{
      r = mid;
    }
  }
  return get_y(lines[r],x);
}

int main(){
  cin >> n >> c;
  REP(i,n){
    ll tmp;
    cin >> tmp;
    h.push_back(tmp);
  }
  ll dp;
  add(p(-2*h[0],c+h[0]*h[0]));
  for(ll i = 1; i < n; i++){
    dp = query(h[i])+h[i]*h[i];
    add(p(-2*h[i],h[i]*h[i]+c+dp));
  }
  cout << dp << endl;
  return 0;
}
