#include<bits/stdc++.h>
using namespace std;

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0);
#define fread           freopen("input.txt","r",stdin);
#define fwrite          freopen("output.txt","w",stdout);
#define nl              "\n"
#define ll              long long
#define ull             unsigned long long
#define mk              make_pair
#define pb              push_back
#define sz(a)           (int)a.size()
#define pii             pair<int,int>
#define pLL             pair<ll,ll>
#define mem(a)          memset(a,-1,sizeof a)
#define clr(a)          memset(a,0,sizeof a)
#define all(a)          a.begin(),a.end()
#define UNIQUE(a)       sort(all(a)),a.erase(unique(all(a)),a.end())
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define ff              first
#define ss              second
#define sq(a)           ((a)*(a))
#define For(i,a,b)      for(int i=a;i<=b;i++)
#define Rof(i,a,b)      for(int i=a;i>=b;i--)
#define Rep(i,b)        for(int i=0;i<b;i++)
#define MOD             1000000007
#define PI              acos(-1.0)
#define eps             1e-9
#define Linf            2e18
#define inf             1<<30
#define MX5             100005
#define MX6             1000006

int dx[] = {-1,+0,+1,+0,+1,+1,-1,-1,+0};
int dy[] = {+0,-1,+0,+1,+1,-1,+1,-1,+0};
//..........................................GEO................................
#define isRight(r,a,b)  ((b.y-r.y)*(a.x-r.x)<(b.x-r.x)*(a.y-r.y))
#define dot(r,a,b)      ((a.x-r.x)*(b.x-r.x)+(a.y-r.y)*(b.y-r.y))
#define ABSDIS(a,r)     (sqrt(sq(a.x-r.x)+sq(a.y-r.y)))
#define angle(r,a,b)    ((180.0*(acos(dot(r,a,b)/(ABSDIS(a,r)*ABSDIS(b,r)))))/PI)
template <typename T> inline T SqrDis(T x1, T y1, T x2, T y2){return sq(x1 - x2) + sq(y1 - y2);}
template <typename T> inline T Area2(T Ax, T Ay, T Bx, T By, T Cx, T Cy){T ret = Ax * (By - Cy) + Bx * (Cy - Ay) + Cx * (Ay - By);
    if(ret < 0) return ret = -ret;return ret;
}
//struct coord{double x,y;bool operator==(coord a){return (x==a.x && y==a.y);}};
//..........................................NT.................................
template <typename T> inline T bigmod(T A,T B,T M = MOD){T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invmod (T A,T M = MOD){return BigMod(A,M-2,M);}

//.........................................END..................................

ll ara[2002];
ll segment[600006];
ll n,x;
void ini(int node, int b, int e){
    if(b>e) return ;
    if(b==e) {
        segment[node]=ara[b];
        return ;
    }
    int mid=(b+e)/2;
    ini(node*2,b,mid);
    ini(node*2+1,mid+1,e);
    segment[node]=min(segment[node*2],segment[node*2+1]);

}
ll query(int node, int b, int e, int f, int g){
    if(b>e) return inf ;
    if(b>g || e<f) return inf;
    if(b>=f && e<=g) return segment[node];
    int mid=(b+e)/2;
    int left=node*2;
    int right=left+1;
    return min(query(left, b,mid,f,g),query(right, mid+1,e, f,g));

}
ll check(ll mid){
    ll sum=0;
    For(i,1,n){
        if(i>=mid){
            ll j=i-mid+1;
            sum+=query(1,1,n,j,i);

        }
        else{
            ll j=i-mid+n+1;
            sum+=min(query(1,1,n,1,i),query(1,1,n,j,n));

        }
    }
    return sum+(mid-1)*x;
}
int main(){
    FastRead


    cin>>n>>x;
    For(i,1,n) cin>>ara[i];
    ini(1,1,n);
    ll low=0, high=n,mid,mid1,mid2,ans;
    while(high-low>=50){
        mid=(high-low)/3;
        mid1=low+mid;
        mid2=high-mid;
        ll a=check(mid1);
        ll b=check(mid2);
        if(a<b){
            ans=a;
            high=mid2;
        }
        else{
            ans=b;
            low=mid1;
        }

    }
    for(int i=low;i<=high;i++){
        ans=min(ans,check(i));
    }
    cout<<ans;




}


Measured memory_bytes: 256