#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define line pair<long long,long long>

int n;
long long C, h[200007];
long long dp[200007];
const long long inf = 1e18;

class ConvexHullTrick{
public:
	deque <line> cur;
	bool bad(line a,line b,line c){
		return ((a.se-b.se)*(c.fi-a.fi)>(b.fi-a.fi)*(a.se-c.se));
	}
	void add(long long A,long long B){
		line p=mp(A,B);
		while((int)cur.size()>=2 && bad(cur[(int)cur.size()-2],cur[(int)cur.size()-1],p)){
			cur.pop_back();
		}
		cur.push_back(p);
	}
	long long query(long long x){
		if(cur.empty()) return inf;
		while((int)cur.size()>=2 && cur[0].fi*x+cur[0].se > cur[1].fi*x+cur[1].se) cur.pop_front();
		return cur[0].fi*x+cur[0].se;
	}
} slope;

int main(){
	ios_base::sync_with_stdio(0);
	cin >> n >> C;
	for(int i = 1; i <= n; i++){
		cin >> h[i];
	}
	dp[1] = 0;
	slope.add(-2LL * h[1], dp[1] + C + h[1] * h[1]);
	for(int i = 2; i <= n; i++){
		dp[i] = slope.query(h[i]) + h[i] * h[i];
		slope.add(-2LL * h[i], dp[i] + C + h[i] * h[i]);
	}
	cout << dp[n];
}
