#define ONLINE_JUDGE //in case i forget to uncomment this, sometimes the grader defines the macro ^.^
#include <cmath>
#ifdef ONLINE_JUDGE
#include <bits/stdc++.h>
#else
#include "stdc++.h"
#endif


#define int long long
using namespace std;

#define MAX(x, y) (((x) > (y)) ? (x) : (y))
#define MIN(x, y) (((x) < (y)) ? (x) : (y))

int N, x;
vector<int> a, costs;

int calculateCosts(int pos) {
    if(costs[pos] == -1) {
        multiset<int> traveler;
        int cost = 0;
        for(int i = 0; i < pos; ++i) traveler.insert(a[i]);
        for(int leftIndex = 0, rightIndex = pos; leftIndex < N; ++leftIndex, ++rightIndex) {
            if(rightIndex >= N) rightIndex = 0;
            if(leftIndex >= N) leftIndex = 0;
            traveler.insert(a[rightIndex]);
            cost += *traveler.begin();
            auto it = traveler.find(a[leftIndex]);
            if(it != traveler.end()) traveler.erase(it);
        }
        cost += x * pos;
        costs[pos] = cost;
    }
    return costs[pos];
}
signed main() {
#ifndef ONLINE_JUDGE
    freopen("/Users/kdkdk/Desktop/input.txt", "r", stdin);
    //freopen("/Users/kdkdk/Desktop/output.txt", "w", stdout);
#endif
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> N >> x;
    a = vector<int>(N);
    costs = vector<int>(N,-1);
    for(int i = 0; i < N; ++i) {
        cin >> a[i];
    }
    
    int minCosts = calculateCosts(0);
    for(int i = 1; i < N; ++i) {
        if(minCosts > calculateCosts(i)) minCosts = calculateCosts(i);
    }
    cout << minCosts << endl;
    
    
    /*
    //binary search over t
    int pos = N/2, step = N/4;
    int lwinpos = -1;
    while(lwinpos == -1) {
        if(pos < 1) pos = 1;
        if(pos > N-1) pos = N-1;
        if(pos == N-1 && calculateCosts(N-2) >= calculateCosts(N-1)) {
            //N-1
            lwinpos = N-1;
        }
        if(pos == 1 && calculateCosts(0) <= calculateCosts(1)) {
            //pos
            lwinpos = 1;
        }
        
        if(pos > N-2) pos = N-2;
        
        if(calculateCosts(pos-1) >= calculateCosts(pos) && calculateCosts(pos) < calculateCosts(pos+1)) {
            lwinpos = pos;
        }
        
        if(calculateCosts(pos-1) >= calculateCosts(pos)) {
            pos += step;
        }
        else pos -= step;
        step /= 2;
        if(step < 1) step = 1;
    }
    
    
    //binary search over t
    pos = N/2, step = N/4;
    int rwinpos = -1;
    while(rwinpos == -1) {
        if(pos < 1) pos = 1;
        if(pos > N-1) pos = N-1;
        if(pos == N-1 && calculateCosts(N-2) >= calculateCosts(N-1)) {
            //N-1
            rwinpos = N-1;
        }
        if(pos == 1 && calculateCosts(0) <= calculateCosts(1)) {
            //pos
            rwinpos = 1;
        }
        
        if(pos > N-2) pos = N-2;
        
        if(calculateCosts(pos-1) > calculateCosts(pos) && calculateCosts(pos) <= calculateCosts(pos+1)) {
            rwinpos = pos;
        }
        
        if(calculateCosts(pos-1) > calculateCosts(pos)) {
            pos += step;
        }
        else pos -= step;
        step /= 2;
        if(step < 1) step = 1;
    }
    */
    
    
    
    return 0;
}

Measured memory_bytes: 384