# include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 55;

struct line{
    long long m, c;
    long long eval(long long x){
        return x * m + c;
    }
    long double inter(line l){
        return (0.0 + l.c - c) / (0.0 + m - l.m);
    }
};

long long n, c, h[N], pt;
line a[N];

int main(){
    cin >> n >> c;

    for(int i = 1; i <= n; i ++){
        cin >> h[i];
    }

    a[++ pt] = {h[1], c + h[1] * h[1]};

    long long ret;

    for(int i = 2; i <= n; i ++){
        ret = h[i] * h[i];
        int lo = 1, hi = pt - 1, id = pt;
        long long x = -2 * h[i];
        while(lo <= hi){
            int md = (lo + hi) >> 1;
            if(a[md].inter(a[md + 1]) <= x)
                hi = md - 1, id = md;
            else
                lo = md + 1;
        }
        ret += a[id].eval(x);
        line cur = {h[i], c + h[i] * h[i] + ret};
        while(pt >= 2 && cur.inter(a[pt]) >= a[pt].inter(a[pt - 1]))
            pt --;
        a[++ pt] = cur;
    }
    cout << ret << endl;
}
