#include<bits/stdc++.h>
#define ll long long
#define int ll
#define pb push_back
#define INF 1e18
#define MOD 1000000007
#define mp make_pair
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define umap unordered_map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x <<"\n"
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
void solve()
{
int n, c;
cin>>n>>c;
int h[n], dp[n];
REP(i, n)
cin>>h[i];
REP(i, n)
dp[i]=LONG_MAX;
dp[0]=0;
REP(i, n)
{
FORD(j, i-1, 0)
{
dp[i]=min(dp[i], dp[j]+(h[i]-h[j])*(h[i]-h[j])+c);
}
}
cout<<dp[n-1];
}
signed main()
{
FastIO
#ifndef ONLINE_JUDGE
freopen(fi, "r", stdin);
freopen(fo, "w", stdout);
#else
// online submission
#endif
int t=1;
//cin>>t;
WL(t){
solve();
if(t!=0)
cout<<"\n";
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBsbCBsb25nIGxvbmcKI2RlZmluZSBpbnQgbGwKI2RlZmluZSBwYiBwdXNoX2JhY2sKI2RlZmluZSBJTkYgMWUxOAojZGVmaW5lIE1PRCAxMDAwMDAwMDA3CiNkZWZpbmUgbXAgbWFrZV9wYWlyCiNkZWZpbmUgUkVQKGksbikgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspCiNkZWZpbmUgRk9SKGksYSxiKSBmb3IgKGludCBpID0gYTsgaSA8IGI7IGkrKykKI2RlZmluZSBSRVBEKGksbikgZm9yIChpbnQgaSA9I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