#include<bits/stdc++.h>
#define LL long long
using namespace std;
int main()
{
    int n,x,a[2005];
    while(~scanf("%d%d",&n,&x)){
        LL sum=0;
        int minn=0x7fffffff,mini;
        for(int i=0;i<n;i++){
            scanf("%d",&a[i]);
            sum+=a[i];
            if(a[i]<minn)mini=i,minn=a[i];
        }
        while(true){
            LL dis=0;
            for(int i=0;i<n-1;i++){
                if(a[(mini-i+n-1)%n]>a[(mini-i+n-2)%n]){
                    dis+=a[(mini-i+n-1)%n]-a[(mini-i+n-2)%n];
                    a[(mini-i+n-1)%n]=a[(mini-i+n-2)%n];
                }
            }
            if(dis<x)break;
            sum-=dis-x;
        }
        printf("%lld\n",sum);
    }
}

