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

void main()
{
    ulong[][] CS;
    ulong[][] MEMO;

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

    CS.length = N;
    MEMO.length = N;
    foreach (i; 0..N) {
        CS[i].length = N;
        MEMO[i].length = N;
    }

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

    foreach (i; 0..N) {
        CS[i][0] = xs[i] * 5 + X * 2;
        foreach (n; 1..i+1) {
            CS[i][n] = CS[i][n-1] - xs[i-n] * (n+1)^^2 + xs[i-n] * (n+2)^^2 + X;
        }
    }

    ulong 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));
}