// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
import std.datetime, std.bigint, std.uni;

int n, x;
int[] a;

void main() {
    scan(n, x);
    a = readln.split.to!(int[]);

    int s = 0, a_min = a[0];
    foreach (i ; 1 .. n) {
        if (a_min > a[i]) {
            s = i;
            a_min = a[i];
        }
    }
    
    int max_span = 0;
    int p = s;

    long ans;

    foreach (i ; 1 .. n + 1) {
        if (a[p] + x > a[(s + i) % n]) {
            int d = ((s + i - 1) % n - p + n) % n;
            ans += (d + 1) * a[p];
            max_span = max(max_span, d);
            p = (s + i) % n;
        }
    }

    debug {
        writeln("max_span:", max_span);
    }

    ans += 1L * max_span * x;

    writeln(ans);
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}