import std.stdio, std.conv, std.math, std.string, std.range, std.array,
       std.algorithm;

void main(){
    auto buf = readln().strip().split().map!(to!long)();
    immutable N = buf[0];
    immutable x = buf[1];

    auto a = readln().strip().split().map!(to!long)().array();

    auto cost = a.dup;
    auto shift = new long[](N);

    for (size_t i = 0; i < N; ++i) {
        for (size_t j = 1; j < N; ++j) {
            auto n = cost[i] + x*j;
            auto p = (i+j)%N;
            if(cost[p] > n) {
                cost[p] = n;
                shift[p] = cast(long)j + shift[i];
            }
        }
    }

    long take;
    for (size_t i = 0; i < N; ++i) {
        take += cost[i] - shift[i] * x;
    }

    writeln(shift.reduce!max * x + take);
}
