#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int read() {
  int f = 1, g = 0;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) g = g * 10 + ch - '0';
  return f * g;
}
int n, l, r;
struct vec {
  long long x, y;
  double slope() { return 1.0 * y / x; }
} que[N];
vec operator-(vec a, vec b) { return (vec){a.x - b.x, a.y - b.y}; }
bool cmpslope(vec a, long long k) { return (a.y / a.x) < k; }
long long m, cur[N], cnt[N], a[N], f[N];
long long A[N], B[N], C[N];
long long calc(int i) { return A[i] + que[l].y - 2 * que[l].x * i; }
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int i = 1; i <= n; i++) {
    cnt[i] = cnt[i - 1] + a[i];
    cur[i] = cur[i - 1] + a[i] + 2 * cnt[i];
  }
  que[1] = (vec){0, 0};
  l = r = 1;
  for (int i = 1; i <= n; i++) {
    A[i] = 2 * a[i] + m * (i + 1) + cur[i];
    while ((l < r) && (cmpslope(que[l + 1] - que[l], 2 * i))) l++;
    f[i] = calc(i);
    B[i] = f[i] - i * m - cur[i] + 2 * cnt[i] * i;
    C[i] = cnt[i];
    vec now = (vec){C[i], B[i]};
    while ((l < r) && ((que[r] - que[r - 1]).slope() > (now - que[r]).slope()))
      r--;
    que[++r] = now;
  }
  printf("%I64d\n", f[n]);
  return 0;
}
