#include <bits/stdc++.h>
using namespace std;
int n,k;
int a[1000000],b[1000000],i=1,sum=0;
int freq[1000000];
string s;
int d=0,dem=0;
int main()
{
    freopen("CAU2_17.inp","r",stdin);
    freopen("CAU2_17.out","w",stdout);
    cin>>n>>k;
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n, greater<int>());
    if (n>=k)
    for (int i=0;i<n;i++)
    {
        if (i%k!=k-1)
        {
            sum=sum+a[i];
        }
    }
    else
    {
        for (int i=0;i<n;i++)
        {
            sum=sum+a[i];
        }
    }
    cout<<sum;
}
