#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
const int N = 200005;
long long x[N];
long long dp[N];
long long sx[N];
long long s1x[N];
long long f(long long s, long long e, long long c) {
  return -2LL * (s1x[e] - s1x[s]) + (2 * e + 3) * (sx[e] - sx[s]) + x[e] * 2 +
         (e - s + 1) * c;
}
int main() {
  long long n, c;
  cin >> n >> c;
  for (int i = (0); i < (n); ++i) scanf("%lld", &x[i + 1]);
  for (int i = (0); i < (n); ++i) sx[i + 1] = sx[i] + x[i + 1];
  for (int i = (0); i < (n); ++i) s1x[i + 1] = s1x[i] + (i + 1) * x[i + 1];
  memset(dp, 0x3f, sizeof(dp));
  dp[0] = 0;
  for (int i = (0); i < (n + 1); ++i) {
    for (int j = (0); j < (i); ++j) {
      dp[i] = min(dp[i], dp[j] + f(j, i, c));
    }
  }
  cout << dp[n] << endl;
  return 0;
}
