Snuke lives in another world, where slimes are real creatures and kept by some people. Slimes come in N colors. Those colors are conveniently numbered 1 through N. Snuke currently has no slime. His objective is to have slimes of all the colors together.

Snuke can perform the following two actions:

* Select a color i (1≤i≤N), such that he does not currently have a slime in color i, and catch a slime in color i. This action takes him a_i seconds.

* Cast a spell, which changes the color of all the slimes that he currently has. The color of a slime in color i (1≤i≤N-1) will become color i+1, and the color of a slime in color N will become color 1. This action takes him x seconds.




Find the minimum time that Snuke needs to have slimes in all N colors.

Constraints

* 2≤N≤2,000
* a_i are integers.
* 1≤a_i≤10^9
* x is an integer.
* 1≤x≤10^9

Input

The input is given from Standard Input in the following format:


N x
a_1 a_2 ... a_N


Output

Find the minimum time that Snuke needs to have slimes in all N colors.

Examples

Input

2 10
1 100


Output

12


Input

3 10
100 1 100


Output

23


Input

4 10
1 2 3 4


Output

10
#include <bits/stdc++.h>
//#include <rng_58>
//#include <chokudai>
//#include <tourist>
using namespace std;
 
// Macro and Macro Functions
#define rep(a, b) for(int a = 0; a < b; ++a)
#define REP(a, b, c) for(int a = b; a < c; ++a)
#define drep(a, b, c) for(int a=0,b=0;b<c?:(b=0,++a<c);++b)
#define int long long
#define SORT(a) sort(ALL(a))
#define RSORT(a) sort(RALL(a))
#define REVERSE(a) reverse(ALL(a))
#define MOD 1000000007
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define ALLIN(a) rep(nanika,a.size()) cin>>a[nanika]
#define ALLINDE(a) rep(kyawa,a.size()){cin>>a[kyawa]; --a[kyawa];}
#define YN(a) do{if(a) cout<<"YES"; else cout<<"NO";}while(0)
#define Yn(a) do{if(a) cout<<"Yes"; else cout<<"No";}while(0)
#define yn(a) do{if(a) cout<<"yes"; else cout<<"no";}while(0)
#define spa " "
#define dspa "  "
#define ctoi(c) (c)-'0'
#define altoi(a) (a)-'a'
#define fi first
#define se second
#define dvec_int(name,row,column,value) vector<vector<int>> name(row,vector<int>(column,value))
 
// List of using
using ll   = signed long long;
using ull  = unsigned long long;
using pint = pair<int,  int>;
using pong = pair<long, long>;
using tint = tuple<int,  int,  int>;
using tong = tuple<long, long, long>;
using vint = vector<int>;
using vll  = vector<long long>;
using vbol = vector<bool>;
using vstr = vector<string>;
using vull = vector<unsigned long long>;
using dvin = vector<vector<int>>;
using dvbo = vector<vector<bool>>;
using mint = map<int,int>;
 
// Common Variable
bool DEBUG=false;
long long INF=2000000000;
 
void print(){
  cout<<'\n';
}
 
template<class HEAD,class... TAIL>
void print(HEAD&& head,TAIL&&... tail){
  cout<<head<<spa;
  print(forward<TAIL>(tail)...);
}
 
void scan(){}
 
template<class HEAD,class... TAIL>
void scan(HEAD&& head,TAIL&&... tail){
  cin>>head;
  scan(forward<TAIL>(tail)...);
}
 
template<typename t>
void print(vector<t> &v){
  rep(i,v.size()){
    cout<<v[i]<<spa;
  }
  cout<<endl;
}
 
template<typename t, typename u>
void print(vector<pair<t,u>> &v){
  rep(i,v.size()){
    cout<<i<<" : "<<v[i].first<<" "<<v[i].second<<endl;
  }
}
 
template<typename t,typename u>
t min(t a,u b){
  return a<=b?a:b;
}
 
//--------------------------------
// Template Place
//--------------------------------
int dx[]={ 1, 0,-1, 0};
int dy[]={ 0,-1, 0, 1};
 
signed main(){
  int n,x; cin>>n>>x;
  vint a(n); ALLIN(a);
  //dvec_int(dp,n,n,0);
  vector<vector<int>> dp(n,vector<int>(n,0));
 
  int ans=0,ans_i=0;
  for(int j=0; j<n; ++j){
    dp[0][j]=a[j];
    ans+=a[j];
  }
  for(int i=1; i<n; ++i){
    int tmp=0;
    for(int j=0; j<n; ++j){
      dp[i][j]=min(dp[i-1][j],a[(j-i+n)%n]);
      tmp+=dp[i][j];
    }
    // print(i,":",tmp,"+",i*x,"=",tmp+i*x,"Minimum :",ans,ans_i);
    tmp+=i*x;
    if(ans>tmp){
      ans=tmp;
      ans_i=i;
    }
  }
 
  // rep(i,n){
  //   rep(j,n){
  //     cout<<setw(4)<<dp[i][j];
  //   }
  //   cout<<endl;
  // }
 
  cout<<ans;
}#include <bits/stdc++.h>
//#include <rng_58>
//#include <chokudai>
//#include <tourist>
using namespace std;
 
// Macro and Macro Functions
#define rep(a, b) for(int a = 0; a < b; ++a)
#define REP(a, b, c) for(int a = b; a < c; ++a)
#define drep(a, b, c) for(int a=0,b=0;b<c?:(b=0,++a<c);++b)
#define int long long
#define SORT(a) sort(ALL(a))
#define RSORT(a) sort(RALL(a))
#define REVERSE(a) reverse(ALL(a))
#define MOD 1000000007
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define ALLIN(a) rep(nanika,a.size()) cin>>a[nanika]
#define ALLINDE(a) rep(kyawa,a.size()){cin>>a[kyawa]; --a[kyawa];}
#define YN(a) do{if(a) cout<<"YES"; else cout<<"NO";}while(0)
#define Yn(a) do{if(a) cout<<"Yes"; else cout<<"No";}while(0)
#define yn(a) do{if(a) cout<<"yes"; else cout<<"no";}while(0)
#define spa " "
#define dspa "  "
#define ctoi(c) (c)-'0'
#define altoi(a) (a)-'a'
#define fi first
#define se second
#define dvec_int(name,row,column,value) vector<vector<int>> name(row,vector<int>(column,value))
 
// List of using
using ll   = signed long long;
using ull  = unsigned long long;
using pint = pair<int,  int>;
using pong = pair<long, long>;
using tint = tuple<int,  int,  int>;
using tong = tuple<long, long, long>;
using vint = vector<int>;
using vll  = vector<long long>;
using vbol = vector<bool>;
using vstr = vector<string>;
using vull = vector<unsigned long long>;
using dvin = vector<vector<int>>;
using dvbo = vector<vector<bool>>;
using mint = map<int,int>;
 
// Common Variable
bool DEBUG=false;
long long INF=2000000000;
 
void print(){
  cout<<'\n';
}
 
template<class HEAD,class... TAIL>
void print(HEAD&& head,TAIL&&... tail){
  cout<<head<<spa;
  print(forward<TAIL>(tail)...);
}
 
void scan(){}
 
template<class HEAD,class... TAIL>
void scan(HEAD&& head,TAIL&&... tail){
  cin>>head;
  scan(forward<TAIL>(tail)...);
}
 
template<typename t>
void print(vector<t> &v){
  rep(i,v.size()){
    cout<<v[i]<<spa;
  }
  cout<<endl;
}
 
template<typename t, typename u>
void print(vector<pair<t,u>> &v){
  rep(i,v.size()){
    cout<<i<<" : "<<v[i].first<<" "<<v[i].second<<endl;
  }
}
 
template<typename t,typename u>
t min(t a,u b){
  return a<=b?a:b;
}
 
//--------------------------------
// Template Place
//--------------------------------
int dx[]={ 1, 0,-1, 0};
int dy[]={ 0,-1, 0, 1};
 
signed main(){
  int n,x; cin>>n>>x;
  vint a(n); ALLIN(a);
  //dvec_int(dp,n,n,0);
  vector<vector<int>> dp(n,vector<int>(n,0));
 
  int ans=0,ans_i=0;
  for(int j=0; j<n; ++j){
    dp[0][j]=a[j];
    ans+=a[j];
  }
  for(int i=1; i<n; ++i){
    int tmp=0;
    for(int j=0; j<n; ++j){
      dp[i][j]=min(dp[i-1][j],a[(j-i+n)%n]);
      tmp+=dp[i][j];
    }
    // print(i,":",tmp,"+",i*x,"=",tmp+i*x,"Minimum :",ans,ans_i);
    tmp+=i*x;
    if(ans>tmp){
      ans=tmp;
      ans_i=i;
    }
  }
 
  // rep(i,n){
  //   rep(j,n){
  //     cout<<setw(4)<<dp[i][j];
  //   }
  //   cout<<endl;
  // }
 
  cout<<ans;
}