#include<bits/stdc++.h>
using namespace std;
bool lf (int64_t a,int64_t b)
{
    return a>b;
}
int main()
{
    freopen ("gifbox.inp","r",stdin);
    freopen ("gifbox.out","w",stdout);
    int64_t n,k,r=0;
    cin>>n>>k;
    int64_t a[n+1];
    for(int64_t i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1,lf);
    for(int i=1;i<=n;i++)
    {
        if(a[i]!=0)
        {
            int64_t trc=a[i];
            r+=trc;
            for(int64_t j=i+1;j<=n;j++)
            {
                if(trc-k>=a[j] && a[j]!=0)
                {
                    trc=a[j];
                    a[j]=0;
                }
            }
        }
    }
    cout<<r;
}
