/// __Macro's__
#include <bits/stdc++.h>
using namespace std;
#define ll                   long long
#define II                   pair<int,int>
#define III                  pair<int, II>
#define VL                   vector<ll>
#define VI                   vector<int>
#define VII                  vector<II>
#define VIII                 vector<III>
#define VVI                  vector<vector<int>>
#define VVII                 vector<vector<II>>
#define fr                   first
#define sc                   second
#define mkpr                 make_pair
#define PQ                   priority_queue
#define pb                   push_back
#define eb                   emplace_back
#define all(v)               v.begin(), v.end()
#define LINE                 putc('\n', stdout)
#define SPACE                putc(' ' , stdout)
#define TAB                  putc('\t', stdout)
#define msg(x)               printf(#x)
#define fillarr(arr, val)    fill((int*)arr, (int*)arr+(sizeof(arr)/sizeof(int)), val)
#define _log2(x)             (31^__builtin_clz(x))
#define INF                  1000000007 
#define MOD                  1000000007 
#define getint ReadInt()
const char IO_MODE = 0; // in-->00<--out (MSB-->LSB) | 0: Norm, 1: Fast 
constexpr ll operator "" _K(unsigned ll n) {return 1000*n;}
constexpr ll operator "" _M(unsigned ll n) {return 1000000*n;}
void operator "" _print(char const* s, size_t n) {printf("%s\n", s);}
inline ll ReadInt(){ll x=0,s=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')s=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+c-'0';
c=getchar();}return s*x;}inline void WriteInt(ll x){char c[20];if(!x){putchar('0');return;}if(x<0)putchar('-'),x=-x;int i=0;while(x>0)
c[++i]=x%10,x/=10;while(i)putchar(c[i--]+48);}template <typename T>inline void out(T x){if(IO_MODE&1)WriteInt(x);else if(typeid(x)==typeid(int))
printf("%i", x);else if(typeid(x)==typeid(ll)) printf("%lld", x);}template<typename T, typename... Args>inline void out(T x,Args...args)
{out(x);SPACE;out(args...);}template <typename T>inline void in(T &x){if(IO_MODE&2) x=ReadInt();else if(typeid(x)==typeid(int))
scanf("%i",&x);else if(typeid(x)==typeid(ll)) scanf("%lld",&x);}template<typename T, typename... Args>
inline void in(T &x,Args&...args){in(x);in(args...);}
int aa,bb,cc,dd,ee,ff,gg,hh,ii,jj,kk,mm,nn,oo,pp,qq,rr,ss,tt,uu,vv,ww,xx,yy,zz;
int tc;
///

// typedef compex<int> point
// #define x real
// #define y imag
// int dot(point a, point b) { return (conj(a)*b).x();}
// int f(point a, int x){ return dot(a, {x, 1});}
#define int long long 
struct Fun{
  int x;
  int p;
}LiChao[(1_M|1)<<2];
int f(Fun c, int y){
  return c.p + (c.x-y)*(c.x-y);
}
void add(Fun d, int p=1, int L=0, int R=1_M|1)
{
  if(d.x>=R) return;
  int m = L+R>>1;
  bool lef = f(d, L) < f(LiChao[p], L);
  bool mid = f(d, m) < f(LiChao[p], m);
  if(mid)      swap(LiChao[p], d);
  if(R-L==1)   return;
  if(lef!=mid) add(d, p<<1,   L, m);
  else         add(d, p<<1|1, m, R); 
}
int rmnq(int x, int p=1, int L=0, int R=1_M|1)
{
  int m = L+R>>1;
  if(R-L==1) return f(LiChao[p], x);
  if(x<m)    return min( f(LiChao[p], x), rmnq(x, p<<1,   L, m) );
  else       return min( f(LiChao[p], x), rmnq(x, p<<1|1, m, R) );
}
int n,c,best;
 main()
{
  in(n,c);
  for(int i=0 ; i<1_M<<2 ; i++)  LiChao[i]=Fun({0,(ll)1e17});
  for(int i=0 ; i<n ; i++)
  {
    int p = getint;
    best = rmnq(p);
    add(Fun({p, (i?best:0)+c}));
  }
  cout << best << endl;

}


Measured memory_bytes: 62848