#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
template <typename T, typename T2>
inline void _max(T &a, T2 b) {
  a = max((T)a, (T)b);
}
template <typename T, typename T2>
inline void _min(T &a, T2 b) {
  a = min((T)a, (T)b);
}
const int MAX = 2e5 + 10;
int n, p, x[MAX];
void clear() {}
void read() {
  assert(n <= MAX);
  for (int i = 0; i < n; i++) scanf("%d", &x[i]);
}
void solve() {
  long long dp[MAX] = {0};
  for (int i = 0; i < MAX; i++) dp[i] = 1e18;
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    long long c = 2ll * x[i] + p;
    for (int j = i; j >= 0; j--) {
      long long t = i - j + 1;
      long long toAdd = x[j] * ((t + 1) * (t + 1) - t * t) + p;
      c += toAdd;
      _min(dp[i + 1], dp[j] + c);
      if (toAdd > 1ll * x[j] * 5 + 2 * p) break;
    }
  }
  printf("%lld\n", dp[n]);
}
int main() {
  while (scanf("%d%d", &n, &p) == 2) {
    clear();
    read();
    solve();
    return 0;
  }
  return 0;
}
