//#define opti
#ifdef opti
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#endif

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

typedef long long int ll;
typedef long long int LL;
typedef unsigned long long int ull;
ll power(ll x,ll y,ll p){ll r=1; x=x%p; while(y){ if(y&1) r= r*x%p; y=y>>1; x=x*x%p; } return r; }
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;*/

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int csrand(int l=0, int r=1e9){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

#define IO              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FILEIO          freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define all(v)          v.begin(),v.end()
#define PR(a)           cout<<"("<<a<<")";
#define ED              cout<<'\n';
#define endl            '\n'
#define loop(j,a,n)     for(int j=a;j<=n;j++)
#define loop1(j,a,n)    for(int j=a;j>=n;j--)
#define fr1(j,n)        for(int j=0;j<n;j++)
#define fr(n)           for(int i=0;i<n;i++)
#define trav(x,s)       for(auto x:s)
#define SC(n)           scanf("%d",&n)
#define PB              push_back
#define MP              make_pair
#define pii             pair<int,int>
#define pll             pair<long long int,long long int>
#define F               first
#define S               second 
#define binf            2000000000000000001
#define mod             1000000007



const int MAXN = (1 << 20);
const int64_t inf = (int64_t)1e18 + 42;

struct convex_hull_trick_max
{
    struct line
    {
        int64_t m, b;
        bool is_query;
        double line_x;

        line() {m = 0; b = 0; line_x = 0; is_query = 0; }
        line(int64_t _m, int64_t _b) {m = _m; b = _b; line_x = 0; is_query = 0; }

        bool operator<(const line &l2) const
        {
            if(!is_query && !l2.is_query) return m < l2.m;
            else return line_x < l2.line_x;
        }

        int64_t value_at(int64_t x) const { return m * x + b; }
    };

    bool parallel(const line &l1, const line &l2) { return l1.m == l2.m; }

    double intersect_x(const line &l1, const line &l2)
    {
        if(parallel(l1, l2)) return (double)inf;
        return (double)(l1.b - l2.b) / (double)(l2.m - l1.m);
    }

    set<line> hull;
    void clear() { hull.clear(); }
    void init() { clear(); }

    bool has_next(set<line>::iterator it) { return it != hull.end() && next(it) != hull.end(); }
    bool has_prev(set<line>::iterator it) { return it != hull.end() && it != hull.begin(); }

    bool irrelevant(const line &l1, const line &l2, const line &l3) { return intersect_x(l1, l3) <= intersect_x(l1, l2); }
    bool irrelevant(set<line>::iterator it) { return has_prev(it) && has_next(it) && irrelevant(*prev(it), *it, *next(it)); }

    set<line>::iterator update_border(set<line>::iterator it)
    {
        line tmp(*it);

        double val;
        if(has_next(it)) val = intersect_x(*it, *next(it));
        else val = inf;

        it = hull.erase(it);
        tmp.line_x = val;
        it = hull.insert(it, tmp);

        return it;
    }

    void add_line(int64_t m, int64_t b)
    {
        line curr_line = line(m, b);
        set<line>::iterator it = hull.lower_bound(curr_line);

        if(it != hull.end() && it->m == m)
        {
            if(it->b < b) it = hull.erase(it);
            else return;
        }

        it = hull.insert(it, curr_line);
        if(irrelevant(it))
        {
            hull.erase(it);
            return;
        }

        while(has_prev(it) && irrelevant(prev(it))) hull.erase(prev(it));
        while(has_next(it) && irrelevant(next(it))) hull.erase(next(it));

        it = update_border(it);
        if(has_prev(it)) update_border(prev(it));
        if(has_next(it)) update_border(next(it));
    }

    int64_t query(int64_t x)
    {
        line to_find;
        to_find.line_x = x;
        to_find.is_query = 1;

        set<line>::iterator best_line = hull.lower_bound(to_find);
        if(best_line == hull.end())
            return inf;

        return best_line->value_at(x);
    }
};

convex_hull_trick_max cht;

const int N=2e5+99;
ll ht[N];

int main() 
{
    IO    
    ll n,c;
    cin>>n>>c;
    fr(n) cin>>ht[i];

    cht.add_line(-2*ht[0],-ht[0]*ht[0]);

    ll ans=0;
    for(int i=1;i<n;i++)
    {
        ll ta=cht.query(-ht[i]);
        ans=-(ht[i]*ht[i]) - c + ta;
        cht.add_line(-2*ht[i],ans-(ht[i]*ht[i]));        
    }

    cout<<abs(ans)<<endl;
      

}




 

Measured memory_bytes: 17408