#include <iostream>
#include<algorithm>
using namespace std;
int main() {
int n , k , total = 0 ,minn = 1900099999;
cin>>n>>k;
int a[n];
for(int i =0 ; i<n ; i++)cin>>a[i];
for(int j = 0 ; j<n ; j++)
{
int sum =j ;
total = 0 ;
for(int i = 0 ; i<n ; i++)
{
if(i != sum) total +=a[i];
else sum +=k;
}
minn = min(minn , total );
}
cout<<minn;
}