// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



#define fRead(x)        freopen(x,"r",stdin)

#define fWrite(x)       freopen (x,"w",stdout)



#define LL              long long

#define ULL             unsigned long long

#define ff              first

#define ss              second

#define pb              push_back

#define INF             5e13

#define PI              acos(-1.0)

#define mk              make_pair

#define pii             pair<int,int>

#define pll             pair<LL,LL>

#define all(a)          a.begin(),a.end()

#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())



#define min3(a,b,c)     min(a,min(b,c))

#define max3(a,b,c)     max(a,max(b,c))

#define min4(a,b,c,d)   min(a,min(b,min(c,d)))

#define max4(a,b,c,d)   max(a,max(b,max(c,d)))

#define SQR(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 MEM(a,x)        memset(a,x,sizeof(a))

#define ABS(x)          ((x)<0?-(x):(x))



#define SORT(v)         sort(v.begin(),v.end())

#define REV(v)          reverse(v.begin(),v.end())



#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);

LL ara[2004];

LL tree[10005];



void update(LL at,LL L,LL R,LL pos,LL val)

{

    if(pos<L or R<pos)return;



    if(pos==L and pos==R)

    {

        tree[at] = val;

        return;

    }



    LL mid = (L+R)/2;

    update(2*at,L,mid,pos,val);

    update(2*at+1,mid+1,R,pos,val);

    tree[at]=min(tree[2*at],tree[2*at+1]);

}



LL query(LL at,LL L,LL R,LL l,LL r)

{

    if(l > r)return 1e18;

    if(r<L or R<l)return 1e18;

    if(l<=L and R<=r)return tree[at];



    LL mid = (L+R)/2;

    LL x = query(2*at,L,mid,l,r);

    LL y = query(2*at+1,mid+1,R,l,r);



    return min(x,y);

}



LL n,x;

inline LL check(LL r)

{

   int bam = - r;

   LL ans = 0;

   for(int i  = 0 ; i < n;i++,bam++){

      LL mn = ara[i];

      int pos = ((bam%n) + n)%n;

      if(pos > i)

      {

         mn = min(mn, query(1,0,n-1,pos,n-1));

         mn = min(mn, query(1,0,n-1,0,i-1));

      }else{

         mn = min(mn, query(1,0,n-1,pos,i-1));

      }

      ans += mn;

   }



   ans = ans + x * r;

   return ans;

}

int main()

{

   FastRead

   cin >> n >> x;



   for(int i = 0;i < n;i++){

      cin >> ara[i];

      update(1,0,n-1,i,ara[i]);

   }



   LL lo = 0, hi = n - 1;

   while(hi - lo > 3)

   {

      LL m1 = (hi-lo)/3 + lo;

      LL m2 = (hi-lo)/3 + m1;

      if(check(m1) > check(m2)){

         lo = m1;

      }else{

         hi = m2;

      }

//      cout << lo << " " << hi << endl;

   }

   LL ans = 4e18;

   for(int i = lo;i<=hi;i++){

//      cout << i << " " << check(i) << endl;

      ans = min(ans,check(i));

   }

   cout << ans << "\n";





}


// Faster C++ solution for the same problem (measured speedup: 5.393238705931265x):
#include<cstdio>

#include<cstring>

using namespace std;

typedef long long LL;

#define MAXN 2000

LL a[MAXN+5];

LL b[MAXN+5][MAXN+5];

LL abs(LL x)

{

	return x>=0 ? x:-x; 

}

LL min(LL x,LL y)

{

	return x<y ? x : y;

}

LL read()

{

	LL x=0,f=1;

	char c=getchar();

	while('0'>c||c>'9'){if(c=='-') f=-1;c=getchar();}

	while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();}

	return x*f;

}

int main()

{

	int n;

    LL x,sum = 1LL << 60LL;

    n=read(),x=read();

    for(int i = 1;i <= n;i++) a[i]=read();

    for(int i = 1;i <= n;i++){

        b[i][0] = a[i];

        for(int k = 1;k <= n - 1;k++){

            int pos = i - k;

            if(pos <= 0) pos = n - abs(pos);

            b[i][k] = min(b[i][k - 1],a[pos]);

        }

    }

    for(int k = 0;k <= n - 1;k++){

        LL ans = 0;

        for(int i = 1;i <= n;i++){

            ans += b[i][k];

        }

        sum = min(sum,ans + x * k);

    }

   printf("%lld\n",sum);

}