import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

long[2000][2000] CS;
long[2000][2000] MEMO;

void main()
{
    auto nx = readln.split.to!(int[]);
    auto N = nx[0];
    auto X = nx[1];

    auto xs = readln.split.to!(long[]);

    foreach (i; 0..N) {
        foreach (n; 0..i+1) {
            long c = xs[i] + X;
            int j = i, g = 2;
            foreach (_k; 0..n) {
                c += (xs[j] - xs[j-1]) * (g++)^^2 + X;
                --j;
            }
            CS[i][n] = c + xs[j] * g^^2 + X;
        }
    }

    long solve(int i, int res) {
        if (MEMO[i][res]) return MEMO[i][res];
        if (i == N-1) {
            return MEMO[i][res] = CS[i][res];
        } else {
            auto r1 = solve(i+1, res+1);
            auto r2 = solve(i+1, 0) + CS[i][res];
            return MEMO[i][res] = min(r1, r2);
        }
    }

    writeln(solve(0, 0));
}