#include <bits/stdc++.h>
int x[200005];
long long dp[200005];
int main() {
  int N, X;
  long long temp;
  scanf("%d%d", &N, &X);
  for (int i = 1; i <= N; i++) scanf("%d", &x[i]);
  for (int i = 1; i <= N; i++) dp[i] = -1;
  for (int i = 1; i <= N; i++) {
    temp = 0;
    for (int j = i - 1; j >= 0; j--) {
      temp += 1LL * (x[j + 1] - x[j]) * (i - j + 1) * (i - j + 1);
      if (dp[i] == -1 ||
          dp[j] + temp + 1LL * x[j] * (i - j + 1) * (i - j + 1) + X + x[i] <
              dp[i])
        dp[i] =
            dp[j] + temp + 1LL * x[j] * (i - j + 1) * (i - j + 1) + X + x[i];
    }
  }
  printf("%lld\n", dp[N] + 1LL * N * X);
  return 0;
}
