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

const int maxn = 2e5 + 5;
int h[maxn];
ll dp[maxn];
int n;
ll c;

#define until first
#define opt second
ll cost(int i, int j) { return dp[j] + ll(h[i] - h[j])*(h[i] - h[j]) + c; }
void solve() {
  dp[n] = 0;
  vector<pair<int,int>> v;
  v.emplace_back(n - 1, n);
  int ipos = 0;
  for (int i = n - 1; i >= 1; i--) {
    while (ipos + 1 < v.size() && i <= v[ipos + 1].until) {
      ipos++;
    }
    dp[i] = cost(i, v[ipos].opt);
    while (v.back().until < i && cost(v.back().until, i) <= cost(v.back().until, v.back().opt)) {
      v.pop_back();
    }
    int l = 1, r = min(i - 1, v.back().until);
    while (l <= r) {
      int mid = (l + r)/2;
      if (cost(mid, i) <= cost(mid, v.back().opt)) l = mid + 1;
      else r = mid - 1;
    }
    if (l - 1 >= 1) {
      v.emplace_back(l - 1, i);
    }
  }
}

int main() {
  cin >> n >> c;
  for (int i = 1; i <= n; i++) {
    cin >> h[i];
  }
  solve();
  cout << dp[1] << '\n';
  return 0;
}
