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;
    auto N = s[0].to!int;
    auto X = s[1].to!long;
    auto A = readln.split.map!(to!long).array;


    int rot = 0;
    long ans = 0;
    foreach (i; 0..N) {
        long tmp = A[i];
        int max_j = i;
        foreach (j; 1..N) {
            if (A[(i-j+N)%N] + j * X <= tmp) {
                tmp = A[(i-j+N)%N] + j * X;
                max_j = (i-j+N)%N;
            }
        }
        rot = max(rot, max_j);
        ans += A[max_j];
    }

    writeln(ans + rot * X);
}
