#include<cstdio>
#include<algorithm>
using namespace std;
int n,x;
int a[2005];
int Min[2005],pos[2005];
int main(){
scanf("%d%d",&n,&x);
for(int i=1;i<=n;++i)scanf("%d",a+i),Min[i]=a[i],pos[i]=i;
long long ans=1ll<<60;
for(int i=0;i<n;++i){
long long tmp=i*1ll*x;
for(int j=1;j<=n;++j){
tmp+=Min[j];
}
for(int j=1;j<=n;++j){
if(pos[j]>1){
--pos[j];
}else{
pos[j]=n;
}
Min[j]=min(Min[j],a[pos[j]]);
}
ans=min(ans,tmp);
}
printf("%lld\n",ans);
return 0;
}
./Main.cpp: In function ‘int main()’:
./Main.cpp:8:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&n,&x);
^
./Main.cpp:9:60: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
for(int i=1;i<=n;++i)scanf("%d",a+i),Min[i]=a[i],pos[i]=i;
^