#include <bits/stdc++.h>
#define pb push_back
#define x first
#define y second
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 2e5 + 100;
const int mod = 1e9 + 7;
struct line
{
    ll k, b;
    line() = default;
    line(ll kk, ll bb)
    {
        k = kk;
        b = bb;
    }
    ll eval(ll x)
    {
        return k * x + b;
    }
};
ld inter(line f, line s)
{
    return 1.0 * (s.b - f.b) / (f.k - s.k);
}
int n;
ll C, h[maxn], dp[maxn], siz, it;
line hull[maxn];
void add(line a)
{
    while(siz >= 2 && inter(hull[siz - 1], hull[siz - 2]) >= inter(hull[siz - 2], a))
        siz--;
    hull[siz++] = a;
}
ll get(ll x)
{
    while(it + 1 < siz && hull[it].eval(x) > hull[it + 1].eval(x))
        it++;
    return hull[it].eval(x);
}
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin >> n >> C;
    for(int i = 0; i < n; i++)
        cin >> h[i];
    add(line(-2 * h[0], h[0] * h[0]));
    for(int i = 1; i < n; i++)
    {
        dp[i] = h[i] * h[i] + get(h[i]) + C;
        add(line(-2 * h[i], h[i] * h[i] + dp[i]));
    }
    cout << dp[n - 1] << "\n";
    return 0;
}
