https://ac.nowcoder.com/acm/contest/332/H
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5, inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
int a[2005], b[2005];
int main()
{
ios::sync_with_stdio(0); cin.tie(0);
int n, x;
cin >> n >> x;
for (int i = 0; i < n; ++i) cin >> a[i];
for (int i = 0; i < n; ++i) b[i] = a[i];
ll ans = INF;
//k枚举的是最大的进化次数,显然小于等于k的进化次数可以通过召唤顺序不同来得到。
//这里有个小dptips,b数组已经保存了所有小于k次的最小值,每次枚举的时候都更新了一下。
for (int k = 0; k < n; ++k){
ll t = k * x;
for (int i = 0; i < n; ++i){
b[i] = min(b[i], a[(i - k + n) % n]);
t += b[i];
}
ans = min(ans, t);
}
cout << ans << endl;
return 0;
}