#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
template <class T> using Trie = trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update>;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int,int> pii;
typedef pair<int,pair<int,int> > ppi;
typedef pair<ld,ld> pdd;

typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ld> vd;
typedef vector<pii> vpii;
typedef vector<ll> vll;
typedef vector<pdd> vdd;
typedef vector<cd> vcd;
typedef vector<ppi> vppi;

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()
#define all(x)  beg(x), en(x)
#define resz(x,a)  x.resize(a)
#define pb push_back
#define as(x,a) x.assign(a)

#define F0R(i,a) for(int i=0;i<(a);++i)
#define FOR(i,a,b) for(int i=a;i<(b);++i)
#define FORD(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define F0RD(i,a) for(int i=(a)-1;i>=0;--i)
#define trav(a,x) for(auto& a : x)

#define fi first
#define se second
#define mp make_pair


#define lb lower_bound
#define ub upper_bound

const int mod = 1000000007;
const ll oo = LLONG_MAX;
const ld pi= acos(-1);

template<class T> void chmax(T&a, T b)  {a=max(a,b);}
template<class T> void chmin(T&a, T b)  {a=min(a,b);}
template<class T> T gcd(T a, T b)  {return b==0 ? a : gcd(b,a%b);}
template<class T> T lcm(T a, T b)  {return a*(b/gcd(a,b));}


int n;
ll c;
typedef complex<ll> point;
class lc_tree
{
private:
    struct node
    {
        node *l,*r;
        point line;
        node() : l(nullptr), r(nullptr), line({0,oo}) { }
    }*rt;
    ll dot(point a, point b) {  return (conj(a)*b).real();}
    ll f_val(point a, int b) {  return dot(a,{b,1});}
    void ins(node *cur, int l, int r, point nw)
    {
        int mid=(l+r)>>1;
        bool M= f_val(nw,mid) < f_val(cur->line,mid);
        bool L= f_val(nw,l)   < f_val(cur->line,l);
        if(M)  swap(cur->line,nw);
        if(r-l==1)  return ;
        if(M!=L)
        {
            if(cur->l==nullptr)  cur->l= new node();
            ins(cur->l,l,mid,nw);
        }
        else
        {
            if(cur->r==nullptr)  cur->r= new node();
            ins(cur->r,mid,r,nw);
        }
    }
    ll query(node *cur, int l, int r, int val)
    {
        ll t=f_val(cur->line,val);
        if(r-l==1)  return t;
        int mid=(l+r)>>1;
        if(cur->l!=nullptr&&val<=mid)  return min(t,query(cur->l,l,mid,val));
        if(cur->r!=nullptr)  return min(t,query(cur->r,mid,r,val));
        return t;
    }
public:
    lc_tree() { rt=new node();}
    void ins(point nw) { ins(rt,0,1e6+10,nw);}
    ll query (int val) { return query(rt,0,1e6+10,val);}
};
vi v;
int main()
{
    //freopen("inp","r",stdin);
    scanf("%d%lld",&n,&c);
    v.resize(n);
    for(int i=0;i<n;++i)  scanf("%d",&v[i]);
    lc_tree lc;
    ll tmp=0ll;
    for(int i=1;i<n;++i)
    {
        lc.ins((point){-2*v[i-1],0ll+tmp+1ll*v[i-1]*v[i-1]});
        tmp=0ll+c+1ll*v[i]*v[i]+lc.query(v[i]);
    }
    cout<<tmp;
    return 0;
}



Measured memory_bytes: 25216