import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto X = s[1].to!long;
    auto A = readln.split.map!(to!long).array;
    auto dp = new Tuple!(long, int)[](N);
    fill(dp, tuple(1L << 59, 1 << 29));

    foreach (i; 0..N) {
        long cost = A[i];
        foreach (jj; 0..N) {
            int j = (i + jj) % N;
            dp[j] = min(dp[j], tuple(cost, jj));
            cost += X;
        }
    }

    long ans = dp.map!(d => d[1]).reduce!max * X;
    foreach (i; 0..N) {
        int j = (i - dp[i][1] + N) % N;
        ans += A[j];
    }

    ans.writeln;
}
