// 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.485637796461017x):
#include <cstdio>



typedef long long LL;



const int MAXN = 4005;



template<typename _T>

void read( _T &x )

{

	x = 0;char s = getchar();int f = 1;

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

	while( s >= '0' && s <= '9' ){x = ( x << 3 ) + ( x << 1 ) + ( s - '0' ), s = getchar();}

	x *= f;

}



template<typename _T>

void write( _T x )

{

	if( x < 0 ){ putchar( '-' ); x = ( ~ x ) + 1; }

	if( 9 < x ){ write( x / 10 ); }

	putchar( x % 10 + '0' );

}



template<typename _T>

_T MIN( const _T a, const _T b )

{

	return a < b ? a : b;

}



int q[MAXN];

int a[MAXN];

int N, x;



LL calc( const int l )

{

	LL ret = 1ll * l * x;

	int h = 1, t = 0, r = 1;

	for( int i = 1 ; i <= N ; i ++ )

	{

		while( h <= t && q[h] < i ) h ++;

		for( ; r <= i + l ; r ++ )

		{

			while( h <= t && a[q[t]] >= a[r] )

				t --;

			q[++ t] = r;

		}

		ret += a[q[h]];

	}

	return ret;

}



int main()

{

	read( N ), read( x );

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

	LL ans = 1e18;

	for( int i = 0 ; i < N ; i ++ )

		ans = MIN( ans, calc( i ) );

	write( ans ), putchar( '\n' );

	return 0;

}