#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int f = 1, sum = 0;
  char x = getchar();
  for (; (x < '0' || x > '9'); x = getchar())
    if (x == '-') f = -1;
  for (; x >= '0' && x <= '9'; x = getchar()) sum = sum * 10 + x - '0';
  return f * sum;
}
int n, K;
int a[2005];
long long f[2005], g[2005][2005];
int main() {
  n = read(), K = read();
  for (int i = 1; i <= n; ++i) a[i] = read();
  for (int i = n; i >= 1; --i) {
    g[i][i] = K;
    for (int j = i - 1; j >= 1; --j)
      g[i][j] =
          g[i][j + 1] + 1ll * (i - j + 1) * (i - j + 1) * (a[j + 1] - a[j]) + K;
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= i - 1; ++j) {
      if (!j)
        f[i] = f[j] + g[i][j + 1] + 1ll * (i - j + 1) * (i - j + 1) * a[j + 1] +
               a[i] + K;
      else
        f[i] = ((f[i]) < (f[j] + g[i][j + 1] +
                          1ll * (i - j + 1) * (i - j + 1) * a[j + 1] + a[i] + K)
                    ? (f[i])
                    : (f[j] + g[i][j + 1] +
                       1ll * (i - j + 1) * (i - j + 1) * a[j + 1] + a[i] + K));
    }
  }
  cout << f[n] << endl;
}
