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

void main()
{
    auto nx = readln.split.to!(long[]);
    auto N = nx[0];
    auto x = nx[1];
    auto as = readln.split.to!(long[]);

    long s, max_s;
    foreach (i; 0..N) {
        long t = long.max;
        foreach (j; 0..N) {
            if (i == j) {
                t = min(t, as[i]);
            } else if (j < i) {
                t = min(t, as[j] + max(i-j - max_s, 0) * x);
            } else {
                t = min(t, as[j] + max(i+N-j - max_s, 0) * x);
            }
        }
        s += t;
        long max_t;
        foreach (j; 0..N) {
            if (j < i && as[j] + max(i-j - max_s, 0) * x == t) {
                max_t = max(max_t, i-j);
            } else if (j > i && as[j] + max(i+N-j - max_s, 0) * x == t) {
                max_t = max(max_t, i+N-j);
            }
        }
        max_s = max(max_s, max_t);
    }
    writeln(s);
}