#include<bits/stdc++.h>
                                    using namespace std;

                                    #define FOR(i,a,b) for(int i = (a); i < (b); i++)
                                    #define rep(i,n) FOR(i,0,n)
                                    #define RFOR(i,b,a) for(int i = (b) - 1; i>= (a); i--)
                                    #define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
                                    #define FILL(a, value) memset(a, value, sizeof(a)

                                    #define SZ(a) (int)a.size()
                                    #define ALL(a) a.begin(), a.end()
                                    #define PB push_back
                                    #define MP make_pair
                                    #define er erase
                                    #define in insert
                                    #define f first
                                    #define s second




                                    typedef  long long LL;
                                    typedef vector<int> VI;
                                    typedef vector<LL > VL;
                                    typedef vector<vector<int > > VVI;
                                    typedef vector<vector<LL>> VVL;
                                    typedef vector <vector<pair<int, int >> >VVPI;
                                    typedef vector<vector<pair<LL, LL >> >VVPL;
                                    typedef vector<pair<LL, LL >> PL;
                                    typedef vector<PL> VPL;
                                    typedef pair<int, int> PII;
                                    typedef pair<LL,LL > PLL ;
                                    typedef vector<PII> VPI;

                                    const double PI = acos(-1.0);
                                    const int INF = 1e9;
                                    const LL LINF = (LL)1e18;

                                    const double EPS = 1e-7;
                                    const int MAS =  3 *1e5 + 10;
                                    const int mod = 998244353;
                                    const int MOD =1e9+7;
                                    const int LOG= 19;
                                    const int ar = 1e5 +100;
                                    const int MAX = 1e6 + 1e2;
                                struct line
                                {
                                    LL a ,b ;
                                    LL val(LL x)
                                    {
                                       return a * x + b;
                                    }
                                    PLL intersect(const line& he)const {
                                        LL one = he.b - b;
                                        LL two = a - he.a;
                                        if(two < 0 )one*=-1,two*=-1;
                                       // assert(two > 0 );
                                        return {one,two};
                                    }

                                };
                                LL square(LL a) {
                                    return a * a;
                                }
                                int main() {
                                    ios_base::sync_with_stdio(false);
                                    cin.tie(NULL);
                                    int n;
                                    cin >> n;
                                    LL c;
                                    cin >> c;
                                    VI h(n);
                                    rep(i,n)cin >> h[i];
                                    vector<line >lines ;
                                    int start = 0;
                                    rep(i,n)
                                    {
                                        while(start <=SZ(lines) -2)
                                        {
                                            line a = lines[start];
                                            line b = lines[start + 1];
                                            if(a.val(h[i]) >=b.val(h[i]))start++;
                                            else break;
                                        }
                                       LL best = 0 ;
                                        if(i!=0)
                                        {
                                            best = lines[start].val(h[i]) + square(h[i]) + c ;
                                        }
                                        line _line{-2 * h[i] ,best + square(h[i])};
                                        while(start <= SZ(lines) - 2 )
                                        {
                                            line A = lines.end()[-2];
                                            line B = lines.end()[-1];
                                            PLL one  =A.intersect(B);
                                            PLL two = B.intersect(_line);
                                            if((__int128)one.first * two.second >=(__int128)one.second * two.first)lines.pop_back() ;
                                            else break;
                                        }
                                            lines.PB(_line);
                                        if(i == n - 1)
                                        {
                                          cout << best;
                                        }
                                    }



                                }

















































Measured memory_bytes: 7280