#include <bits/stdc++.h>

using namespace std;
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
long long a[200000];
long long q[200000],w[200000],sum[200000];
int main()
{
    IOS;
    long long n,d,m;
    cin>>n>>d>>m;
    int qq=0,ww=0;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(a[i]>m)
        {
            qq++;
            q[qq]=a[i];
        }
        else
        {
            ww++;
            w[ww]=a[i];
        }
    }
    sort(q+1,q+1+qq);
    sort(w+1,w+1+ww);
    for(int i=1; i<=ww; i++)
    {
        sum[i]=sum[i-1]+w[i];
    }
    long long ans=0;
    ans+=q[qq];
    int k=0;
    int e=0;
    int tt=0;
    for(int i=1; i<=qq-1; i++)
    {
        if(q[i]>=(sum[k+(d-e)]-sum[k])&&(k+(d-e))<=ww)
        {
            k+=(d-e);
            e=0;
            ans+=q[i];
        }
        else
        {
            if(e>=d)
            {
                ans+=q[i];
                e-=d;
            }
            else
            {
                e++;
            }
        }
    }
    ans+=(sum[ww]-sum[k]);
    cout<<ans;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
long long a[200000];
long long q[200000],w[200000],sum[200000];
int main()
{
    IOS;
    long long n,d,m;
    cin>>n>>d>>m;
    int qq=0,ww=0;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(a[i]>m)
        {
            qq++;
            q[qq]=a[i];
        }
        else
        {
            ww++;
            w[ww]=a[i];
        }
    }
    sort(q+1,q+1+qq);
    sort(w+1,w+1+ww);
    for(int i=1; i<=ww; i++)
    {
        sum[i]=sum[i-1]+w[i];
    }
    long long ans=0;
    ans+=q[qq];
    int k=0;
    int e=0;
    int tt=0;
    for(int i=1; i<=qq-1; i++)
    {
        if(q[i]>(sum[k+(d-e)]-sum[k])&&(k+(d-e))<=ww)
        {
            k+=(d-e);
            e=0;
            tt++;
        }
        else
        {
            if(e>=d)
            {
                tt++;
                e-=d;
            }
            else
            {
                e++;
            }
        }
    }
    qq--;
    for(int i=1;i<=tt;i++)
    {
        ans+=q[qq];
        qq--;
    }
    if(n==100000&&d==958&&m==518)
    {
        cout<<sum[k]-sum[k-e]<<" "<<tt<<" "<<k<<endl;
    }
    ans+=(sum[ww]-sum[k]);
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
long long a[200000];
long long q[200000],w[200000],sum[200000];
bool cmp(long long x,long long y)
{
    return x>y;
}
int main()
{
    IOS;
    long long n,d,m;
    cin>>n>>d>>m;
    int qq=0,ww=0;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(a[i]>m)
        {
            qq++;
            q[qq]=a[i];
        }
        else
        {
            ww++;
            w[ww]=a[i];
        }
    }
    sort(q+1,q+1+qq,cmp);
    sort(w+1,w+1+ww,cmp);
    for(int i=1; i<=ww; i++)
    {
        sum[i]=sum[i-1]+w[i];
    }
    long long ans=0,sum1=sum[ww];
    int k=0;
    int e=0;
    int tt=0;
    for(int i=1; i<=qq; i++)
    {
        ans+=q[i];
        tt=(i-1)*(d+1)+1;
        if(tt>n) break;
        sum1=max(sum1,ans+sum[n-tt]);
    }
    cout<<sum1;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
long long a[200000];
long long q[200000],w[200000],sum[200000];
int main()
{
    IOS;
    long long n,d,m;
    cin>>n>>d>>m;
    int qq=0,ww=0;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(a[i]>m)
        {
            qq++;
            q[qq]=a[i];
        }
        else
        {
            ww++;
            w[ww]=a[i];
        }
    }
    sort(q+1,q+1+qq);
    sort(w+1,w+1+ww);
    for(int i=1; i<=ww; i++)
    {
        sum[i]=sum[i-1]+w[i];
    }
    long long ans=0;
    ans+=q[qq];
    int k=0;
    int e=0;
    int tt=0;
    for(int i=1; i<=qq-1; i++)
    {
        if(q[i]>(sum[k+(d-e)]-sum[k])&&(k+(d-e))<=ww)
        {
            k+=(d-e);
            e=0;
            tt++;
        }
        else
        {
            if(e>=d)
            {
                tt++;
                e-=d;
            }
            else
            {
                e++;
            }
        }
    }
    qq--;
    for(int i=1;i<=tt;i++)
    {
        ans+=q[qq];
        qq--;
    }
    if(n==100000&&d==958&&m==518)
    {
        cout<<ww<<" "<<tt<<" "<<k<<endl;
    }
    ans+=(sum[ww]-sum[k]);
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
long long a[200000];
long long q[200000],w[200000],sum[200000];
int main()
{
    IOS;
    long long n,d,m;
    cin>>n>>d>>m;
    int qq=0,ww=0;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(a[i]>m)
        {
            qq++;
            q[qq]=a[i];
        }
        else
        {
            ww++;
            w[ww]=a[i];
        }
    }
    sort(q+1,q+1+qq);
    sort(w+1,w+1+ww);
    for(int i=1; i<=ww; i++)
    {
        sum[i]=sum[i-1]+w[i];
    }
    long long ans=0;
    ans+=q[qq];
    int k=0;
    int e=0;
    int tt=0;
    for(int i=1; i<=qq-1; i++)
    {
        if(q[i]>(sum[k+(d-e)]-sum[k])&&(k+(d-e))<=ww)
        {
            k+=(d-e);
            e=0;
            tt++;
        }
        else
        {
            if(e>=d)
            {
                tt++;
                e-=d;
            }
            else
            {
                e++;
            }
        }
    }
    qq--;
    for(int i=1;i<=tt;i++)
    {
        ans+=q[qq];
        qq--;
    }
    if(k-e>=0)
    ans+=(sum[ww]-sum[k-e]);
    else
    {
        ans+=(sum[ww]-sum[0]);
    }
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
long long a[200000];
long long q[200000],w[200000],sum[200000];
int main()
{
    IOS;
    long long n,d,m;
    cin>>n>>d>>m;
    int qq=0,ww=0;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(a[i]>m)
        {
            qq++;
            q[qq]=a[i];
        }
        else
        {
            ww++;
            w[ww]=a[i];
        }
    }
    sort(q+1,q+1+qq);
    sort(w+1,w+1+ww);
    for(int i=1; i<=ww; i++)
    {
        sum[i]=sum[i-1]+w[i];
    }
    long long ans=0;
    int k=0;
    int e=0;
    int tt=0;
    for(int i=1; i<=qq; i++)
    {
        if(q[i]>(sum[k+(d-e)]-sum[k])&&(k+(d-e))<=ww)
        {
            k+=(d-e);
            e=0;
            tt++;
        }
        else
        {
            e++;
        }
    }
    for(int i=1;i<=tt+1;i++)
    {
        ans+=q[qq];
        qq--;
    }
    if(k-e>=0)
    ans+=(sum[ww]-sum[k-e]);
    else
    {
        ans+=(sum[ww]-sum[0]);
    }
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
long long a[200000];
long long q[200000],w[200000],sum[200000];
int main()
{
    IOS;
    long long n,d,m;
    cin>>n>>d>>m;
    int qq=0,ww=0;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(a[i]>m)
        {
            qq++;
            q[qq]=a[i];
        }
        else
        {
            ww++;
            w[ww]=a[i];
        }
    }
    sort(q+1,q+1+qq);
    sort(w+1,w+1+ww);
    for(int i=1; i<=ww; i++)
    {
        sum[i]=sum[i-1]+w[i];
    }
    long long ans=0;
    int k=0;
    int e=0;
    int tt=0;
    for(int i=1; i<=qq; i++)
    {
        if(q[i]>(sum[k+(d-e)]-sum[k])&&(k+(d-e))<=ww)
        {
            k+=(d-e);
            e=0;
            tt++;
        }
        else
        {
            e++;
        }
    }
    e--;
    for(int i=1;i<=tt+1;i++)
    {
        ans+=q[qq];
        qq--;
    }
    if(k-e>=0)
    ans+=(sum[ww]-sum[k-e]);
    else
    {
        ans+=(sum[ww]-sum[0]);
    }
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
long long a[200000];
long long q[200000],w[200000],sum[200000];
bool cmp(long long x,long long y)
{
    return x>y;
}
int main()
{
    IOS;
    long long n,d,m;
    cin>>n>>d>>m;
    int qq=0,ww=0;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(a[i]>m)
        {
            qq++;
            q[qq]=a[i];
        }
        else
        {
            ww++;
            w[ww]=a[i];
        }
    }
    sort(q+1,q+1+qq,cmp);
    sort(w+1,w+1+ww,cmp);
    for(int i=1; i<=ww; i++)
    {
        sum[i]=sum[i-1]+w[i];
    }
    long long ans=0,sum1=0;
    int k=0;
    int e=0;
    int tt=0;
    for(int i=1; i<=qq; i++)
    {
        ans+=q[i];
        tt=(i-1)*(d+1)+1;
        if(tt>n) break;
        sum1=max(sum1,ans+sum[n-tt]);
    }
    cout<<sum1;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
long long a[200000];
long long q[200000],w[200000],sum[200000];
int main()
{
    IOS;
    long long n,d,m;
    cin>>n>>d>>m;
    int qq=0,ww=0;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(a[i]>m)
        {
            qq++;
            q[qq]=a[i];
        }
        else
        {
            ww++;
            w[ww]=a[i];
        }
    }
    sort(q+1,q+1+qq);
    sort(w+1,w+1+ww);
    for(int i=1; i<=ww; i++)
    {
        sum[i]=sum[i-1]+w[i];
    }
    long long ans=0;
    int k=0;
    int e=0;
    int tt=0;
    for(int i=2; i<=qq; i++)
    {
        if(q[i]>(sum[k+(d-e)]-sum[k])&&(k+(d-e))<=ww)
        {
            k+=(d-e);
            e=0;
            tt++;
        }
        else
        {
            e++;
        }
    }
    for(int i=1;i<=tt+1;i++)
    {
        ans+=q[qq];
        qq--;
    }
    if(k-e>=0)
    ans+=(sum[ww]-sum[k-e]);
    else
    {
        ans+=(sum[ww]-sum[0]);
    }
    cout<<max(ans,sum[ww]);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
long long a[200000];
long long q[200000],w[200000],sum[200000];
int main()
{
    IOS;
    long long n,d,m;
    cin>>n>>d>>m;
    int qq=0,ww=0;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(a[i]>m)
        {
            qq++;
            q[qq]=a[i];
        }
        else
        {
            ww++;
            w[ww]=a[i];
        }
    }
    sort(q+1,q+1+qq);
    sort(w+1,w+1+ww);
    for(int i=1; i<=ww; i++)
    {
        sum[i]=sum[i-1]+w[i];
    }
    long long ans=0;
    ans+=q[qq];
    int k=0;
    int e=0;
    int tt=0;
    for(int i=1; i<=qq-1; i++)
    {
        if(q[i]>(sum[k+(d-e)]-sum[k])&&(k+(d-e))<=ww)
        {
            k+=(d-e);
            e=0;
            tt++;
        }
        else
        {
            if(e>=d)
            {
                tt++;
                e-=d;
            }
            else
            {
                e++;
            }
        }
    }
    qq--;
    for(int i=1;i<=tt;i++)
    {
        ans+=q[qq];
        qq--;
    }
    ans+=(sum[ww]-sum[k]);
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
long long a[200000];
long long q[200000],w[200000],sum[200000];
int main()
{
    IOS;
    long long n,d,m;
    cin>>n>>d>>m;
    int qq=0,ww=0;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(a[i]>m)
        {
            qq++;
            q[qq]=a[i];
        }
        else
        {
            ww++;
            w[ww]=a[i];
        }
    }
    sort(q+1,q+1+qq);
    sort(w+1,w+1+ww);
    for(int i=1; i<=ww; i++)
    {
        sum[i]=sum[i-1]+w[i];
    }
    long long ans=0;
    int k=0;
    int e=0;
    int tt=0;
    for(int i=2; i<=qq; i++)
    {
        if(q[i]>(sum[k+(d-e)]-sum[k])&&(k+(d-e))<=ww)
        {
            k+=(d-e);
            e=0;
            tt++;
        }
        else
        {
            e++;
        }
    }
    for(int i=1;i<=tt+1;i++)
    {
        ans+=q[qq];
        qq--;
    }
    if(k-e>=0)
    ans+=(sum[ww]-sum[k-e]);
    else
    {
        ans+=(sum[ww]-sum[0]);
    }
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
long long a[200000];
long long q[200000],w[200000],sum[200000];
bool cmp(long long x,long long y)
{
    return x>y;
}
int main()
{
    IOS;
    long long n,d,m;
    cin>>n>>d>>m;
    int qq=0,ww=0;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(a[i]>m)
        {
            qq++;
            q[qq]=a[i];
        }
        else
        {
            ww++;
            w[ww]=a[i];
        }
    }
    sort(q+1,q+1+qq,cmp);
    sort(w+1,w+1+ww,cmp);
    for(int i=1; i<=n; i++)
    {
        sum[i]=sum[i-1]+w[i];
    }
    long long ans=0,sum1=sum[n];
    int k=0;
    int e=0;
    int tt=0;
    for(int i=1; i<=qq; i++)
    {
        ans+=q[i];
        tt=(i-1)*(d+1)+1;
        if(tt>n) break;
        sum1=max(sum1,ans+sum[n-tt]);
    }
    cout<<sum1;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
long long a[200000];
long long q[200000],w[200000],sum[200000];
int main()
{
    IOS;
    long long n,d,m;
    cin>>n>>d>>m;
    int qq=0,ww=0;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(a[i]>m)
        {
            qq++;
            q[qq]=a[i];
        }
        else
        {
            ww++;
            w[ww]=a[i];
        }
    }
    sort(q+1,q+1+qq);
    sort(w+1,w+1+ww);
    for(int i=1; i<=ww; i++)
    {
        sum[i]=sum[i-1]+w[i];
    }
    long long ans=0;
    ans+=q[qq];
    int k=0;
    int e=0;
    int tt=0;
    for(int i=1; i<=qq-1; i++)
    {
        if(q[i]>(sum[k+d]-sum[k])&&(k+d)<=ww)
        {
            ans+=q[i];
            k+=d;
        }
        else
        {
            if(e==d)
            {
                ans+=q[i];
                e=0;
            }
            else
            {
                if(k+d>ww&&tt==0&&(ww-k+e)>=d&&q[i]>(sum[ww]-sum[k]))
                {
                    k+=(d-e);
                    e=0;
                    ans+=q[i];
                    if(k==ww)
                    {
                        tt=1;
                    }
                }
                else
                {
                    e++;
                }
            }

        }
    }
    ans+=(sum[ww]-sum[k]);
    cout<<ans;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
long long a[200000];
long long q[200000],w[200000],sum[200000];
int main()
{
    IOS;
    long long n,d,m;
    cin>>n>>d>>m;
    int qq=0,ww=0;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(a[i]>m)
        {
            qq++;
            q[qq]=a[i];
        }
        else
        {
            ww++;
            w[ww]=a[i];
        }
    }
    sort(q+1,q+1+qq);
    sort(w+1,w+1+ww);
    for(int i=1; i<=ww; i++)
    {
        sum[i]=sum[i-1]+w[i];
    }
    long long ans=0;
    ans+=q[qq];
    int k=0;
    int e=0;
    int tt=0;
    for(int i=1; i<=qq-1; i++)
    {
        if(q[i]>(sum[k+(d-e)]-sum[k])&&(k+(d-e))<=ww)
        {
            k+=(d-e);
            e=0;
            ans+=q[i];
        }
        else
        {
            if(e==d)
            {
                ans+=q[i];
                e=0;
            }
            else
            {
                e++;
            }
        }
    }
    ans+=(sum[ww]-sum[k]);
    cout<<ans;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
long long a[200000];
long long q[200000],w[200000],sum[200000];
int main()
{
    IOS;
    long long n,d,m;
    cin>>n>>d>>m;
    int qq=0,ww=0;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(a[i]>m)
        {
            qq++;
            q[qq]=a[i];
        }
        else
        {
            ww++;
            w[ww]=a[i];
        }
    }
    sort(q+1,q+1+qq);
    sort(w+1,w+1+ww);
    for(int i=1; i<=ww; i++)
    {
        sum[i]=sum[i-1]+w[i];
    }
    long long ans=0;
    ans+=q[qq];
    int k=0;
    int e=0;
    int tt=0;
    for(int i=1; i<=qq-1; i++)
    {
        if(q[i]>(sum[k+(d-e)]-sum[k])&&(k+(d-e))<=ww)
        {
            k+=(d-e);
            e=0;
            tt++;
        }
        else
        {
            if(e>=d)
            {
                tt++;
                e-=d;
            }
            else
            {
                e++;
            }
        }
    }
    qq--;
    for(int i=1;i<=tt;i++)
    {
        ans+=q[qq];
        qq--;
    }
    if(n==100000&&d==958&&m==518)
    {
        cout<<e<<" "<<tt<<" "<<k<<endl;
    }
    ans+=(sum[ww]-sum[k]);
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
long long a[200000];
long long q[200000],w[200000],sum[200000];
int main()
{
    IOS;
    long long n,d,m;
    cin>>n>>d>>m;
    int qq=0,ww=0;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(a[i]>m)
        {
            qq++;
            q[qq]=a[i];
        }
        else
        {
            ww++;
            w[ww]=a[i];
        }
    }
    sort(q+1,q+1+qq);
    sort(w+1,w+1+ww);
    for(int i=1; i<=ww; i++)
    {
        sum[i]=sum[i-1]+w[i];
    }
    long long ans=0;
    ans+=q[qq];
    int k=0;
    int e=0;
    int tt=0;
    for(int i=1; i<=qq-1; i++)
    {
        if(q[i]>(sum[k+d]-sum[k])&&(k+d)<=ww)
        {
            ans+=q[i];
            k+=d;
        }
        else
        {
            if(e==d)
            {
                ans+=q[i];
                e=0;
            }
            else
            {
                if(q[i]>(sum[k+(d-e)]-sum[k])&&(k+(d-e))<=ww)
                {
                    k+=(d-e);
                    e=0;
                    ans+=q[i];
                }
                else
                {
                    e++;
                }
            }
        }
    }
    ans+=(sum[ww]-sum[k]);
    cout<<ans;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
long long a[200000];
long long q[200000],w[200000],sum[200000];
int main()
{
    IOS;
    long long n,d,m;
    cin>>n>>d>>m;
    int qq=0,ww=0;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(a[i]>m)
        {
            qq++;
            q[qq]=a[i];
        }
        else
        {
            ww++;
            w[ww]=a[i];
        }
    }
    sort(q+1,q+1+qq);
    sort(w+1,w+1+ww);
    for(int i=1; i<=ww; i++)
    {
        sum[i]=sum[i-1]+w[i];
    }
    long long ans=0;
    ans+=q[qq];
    int k=0;
    int e=0;
    int tt=0;
    for(int i=1; i<=qq-1; i++)
    {
        if(q[i]>(sum[k+(d-e)]-sum[k])&&(k+(d-e))<=ww)
        {
            k+=(d-e);
            e=0;
            ans+=q[i];
        }
        else
        {
            if(e>=d)
            {
                ans+=q[i];
                e-=d;
            }
            else
            {
                e++;
            }
        }
    }
    ans+=(sum[ww]-sum[k]);
    cout<<ans;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
long long a[200000];
long long q[200000],w[200000],sum[200000];
int main()
{
    IOS;
    long long n,d,m;
    cin>>n>>d>>m;
    int qq=0,ww=0;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(a[i]>m)
        {
            qq++;
            q[qq]=a[i];
        }
        else
        {
            ww++;
            w[ww]=a[i];
        }
    }
    sort(q+1,q+1+qq);
    sort(w+1,w+1+ww);
    for(int i=1; i<=ww; i++)
    {
        sum[i]=sum[i-1]+w[i];
    }
    long long ans=0;
    ans+=q[qq];
    int k=0;
    int e=0;
    int tt=0;
    for(int i=1; i<=qq-1; i++)
    {
        if(q[i]>(sum[k+(d-e)]-sum[k])&&(k+(d-e))<=ww)
        {
            k+=(d-e);
            e=0;
            tt++;
        }
        else
        {
            if(e>=d)
            {
                tt++;
                e-=d;
            }
            else
            {
                e++;
            }
        }
    }
    qq--;
    for(int i=1;i<=tt;i++)
    {
        ans+=q[qq];
        qq--;
    }
    if(k-e>=0)
    ans+=(sum[ww]-sum[k-e]);
    else
    {
        ans+=(sum[ww]-sum[0])
    }
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
long long a[200000];
long long q[200000],w[200000],sum[200000];
int main()
{
    IOS;
    long long n,d,m;
    cin>>n>>d>>m;
    int qq=0,ww=0;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(a[i]>m)
        {
            qq++;
            q[qq]=a[i];
        }
        else
        {
            ww++;
            w[ww]=a[i];
        }
    }
    sort(q+1,q+1+qq);
    sort(w+1,w+1+ww);
    for(int i=1; i<=ww; i++)
    {
        sum[i]=sum[i-1]+w[i];
    }
    long long ans=0;
    ans+=q[qq];
    int k=0;
    int e=0;
    int tt=0;
    for(int i=1; i<=qq-1; i++)
    {
        if(q[i]>(sum[k+(d-e)]-sum[k])&&(k+(d-e))<=ww)
        {
            k+=(d-e);
            e=0;
            tt++;
        }
        else
        {
            if(e>=d)
            {
                tt++;
                e-=d;
            }
            else
            {
                e++;
            }
        }
    }
    qq--;
    for(int i=1;i<=tt;i++)
    {
        ans+=q[qq];
        qq--;
    }
    if(n==100000&&d==958&&m==518)
    {
        cout<<tt<<" "<<k<<endl;
    }
    ans+=(sum[ww]-sum[k]);
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

/* // Ordered Set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)
// int ncr(int n,int r) {return (fact[n]*modInv(fact[r]))%mod*modInv(fact[n-r])%mod;}
// int modInv(int i) {return binExp(i,mod-2);}

signed main()
{
    fast

    #ifndef ONLINE_JUDGE
        freopen("inputf.in","r",stdin);
        freopen("outputf.in","w",stdout);
    #endif

    int n,d,m;
    cin>>n>>d>>m;

    vi a(n);
    int problem = 0;
    f0(i,0,n)
    {
    	cin>>a[i];
    	if(a[i] > m) problem++;
    }
    sort(all(a), greater<int>());

    int pre[n+1];
    pre[0] = 0;
    f1(i,1,n)
    {
    	pre[i] = pre[i-1] + a[i-1];
    }

    int ans = 0;
    if(problem == 0)
    {
    	ans += pre[n];
    }
    else
    {
	    f1(i,1,problem)
	    {
	    	if((i-1)*(d+1)+1 > n) continue;
	    	if(problem > (i-1)*(d+1)+1) continue;
	    	int cur = pre[i];
	    	int lim = problem + n-((i-1)*(d+1)+1);
	    	cur += pre[lim] - pre[problem];
	    	ans = max(ans, cur);
	    }
	}

    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;

/* // Ordered Set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)
// int ncr(int n,int r) {return (fact[n]*modInv(fact[r]))%mod*modInv(fact[n-r])%mod;}
// int modInv(int i) {return binExp(i,mod-2);}

signed main()
{
    fast

    #ifndef ONLINE_JUDGE
        freopen("inputf.in","r",stdin);
        freopen("outputf.in","w",stdout);
    #endif

    int n,d,m;
    cin>>n>>d>>m;

    vi problem;
    vi normal;
    int x;
    f0(i,0,n)
    {
    	cin>>x;
    	if(x > m) problem.pb(x);
    	else normal.pb(x);
    }
    sort(all(problem), greater<int>());
    sort(all(normal), greater<int>());

    int ans = 0;
    if(problem.size() == 0)
    {
    	for(auto x : normal) ans += x;
    }
    else
    {
	    int prep[problem.size()+1];
	    int pren[normal.size()+1];

	    prep[0] = pren[0] = 0;
	    f1(i,1,problem.size())
	    {
	    	prep[i] = prep[i-1] + problem[i-1];
	    }
	    f1(i,1,normal.size())
	    {
	    	pren[i] = pren[i-1] + normal[i-1];
	    }

	    f1(i,1,problem.size())
	    {
	    	if((i-1)*(d+1)+1 < problem.size()) continue;
	    	if((i-1)*(d+1)+1 > n) break;
	    	// cout<<i<<' '<<(i-1)*(d+1)+1<<'\n';
	    	ans = max(ans, prep[i] + pren[n - ((i-1)*(d+1)+1)]);
	    }

	}

    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;

/* // Ordered Set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)
// int ncr(int n,int r) {return (fact[n]*modInv(fact[r]))%mod*modInv(fact[n-r])%mod;}
// int modInv(int i) {return binExp(i,mod-2);}

signed main()
{
    fast

    #ifndef ONLINE_JUDGE
        freopen("inputf.in","r",stdin);
        freopen("outputf.in","w",stdout);
    #endif

    int n,d,m;
    cin>>n>>d>>m;

    vll problem;
    vll normal;
    int x;
    f0(i,0,n)
    {
    	cin>>x;
    	if(x > m) problem.pb(x);
    	else normal.pb(x);
    }
    sort(all(problem), greater<int>());
    sort(all(normal), greater<int>());

    int ans = 0;
    if(problem.size() == 0)
    {
    	for(auto x : normal) ans += x;
    }
    else
    {
	    vll prep(problem.size()+1);
	    vll pren(normal.size()+1);

	    prep[0] = pren[0] = 0;
	    f1(i,1,problem.size())
	    {
	    	prep[i] = prep[i-1] + problem[i-1];
	    }
	    f1(i,1,normal.size())
	    {
	    	pren[i] = pren[i-1] + normal[i-1];
	    }
	    f1(i,normal.size()+1,n)
	    {
	    	pren.pb(pren[normal.size()]);
	    }

	    f1(i,(problem.size()+d)/(1+d),problem.size())
	    {
	    	if((i-1)*(d+1)+1 <= n)
	    	{
		    	// cout<<i<<' '<<(i-1)*(d+1)+1<<'\n';
		    	ans = max(ans, prep[i] + pren[n - ((i-1)*(d+1)+1)]);
	    	}
	    }

	}

    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;

/* // Ordered Set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)
// int ncr(int n,int r) {return (fact[n]*modInv(fact[r]))%mod*modInv(fact[n-r])%mod;}
// int modInv(int i) {return binExp(i,mod-2);}

signed main()
{
    fast

    #ifndef ONLINE_JUDGE
        freopen("inputf.in","r",stdin);
        freopen("outputf.in","w",stdout);
    #endif

    int n,d,m;
    cin>>n>>d>>m;

    vi a(n);
    int problem = 0;
    f0(i,0,n)
    {
    	cin>>a[i];
    	if(a[i] > m) problem++;
    }
    sort(all(a), greater<int>());

    int pre[n+1];
    pre[0] = 0;
    f1(i,1,n)
    {
    	pre[i] = pre[i-1] + a[i-1];
    }

    int ans = 0;
    if(problem == 0)
    {
    	ans += pre[n];
    }
    else
    {
	    f1(i,ceil(double(problem-1)/double(d+1))+1,(n-1)/(d+1)+1)
	    {
	    	int cur = pre[i];
	    	int lim = problem + n-((i-1)*(d+1)+1);
	    	cur += pre[lim] - pre[problem];
	    	ans = max(ans, cur);
	    }
	}

    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;

/* // Ordered Set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)
// int ncr(int n,int r) {return (fact[n]*modInv(fact[r]))%mod*modInv(fact[n-r])%mod;}
// int modInv(int i) {return binExp(i,mod-2);}

signed main()
{
    fast

    #ifndef ONLINE_JUDGE
        freopen("inputf.in","r",stdin);
        freopen("outputf.in","w",stdout);
    #endif

    int n,d,m;
    cin>>n>>d>>m;

    vll problem;
    vll normal;
    int x;
    f0(i,0,n)
    {
    	cin>>x;
    	if(x > m) problem.pb(x);
    	else normal.pb(x);
    }
    sort(all(problem), greater<int>());
    sort(all(normal), greater<int>());

    int ans = 0;
    if(problem.size() == 0)
    {
    	for(auto x : normal) ans += x;
    }
    else
    {
	    int prep[problem.size()+1];
	    int pren[normal.size()+1];

	    prep[0] = pren[0] = 0;
	    f1(i,1,problem.size())
	    {
	    	prep[i] = prep[i-1] + problem[i-1];
	    }
	    f1(i,1,normal.size())
	    {
	    	pren[i] = pren[i-1] + normal[i-1];
	    }

	    f1(i,(problem.size()+d)/(1+d),problem.size())
	    {
	    	if((i-1)*(d+1)+1 <= n)
	    	{
		    	// cout<<i<<' '<<(i-1)*(d+1)+1<<'\n';
		    	ans = max(ans, prep[i] + pren[n - ((i-1)*(d+1)+1)]);
	    	}
	    }

	}

    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;

/* // Ordered Set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)
// int ncr(int n,int r) {return (fact[n]*modInv(fact[r]))%mod*modInv(fact[n-r])%mod;}
// int modInv(int i) {return binExp(i,mod-2);}

signed main()
{
    fast

    #ifndef ONLINE_JUDGE
        freopen("inputf.in","r",stdin);
        freopen("outputf.in","w",stdout);
    #endif

    int n,d,m;
    cin>>n>>d>>m;

    vi a(n);
    int problem = 0;
    f0(i,0,n)
    {
    	cin>>a[i];
    	if(a[i] > m) problem++;
    }
    sort(all(a), greater<int>());

    int pre[n+1];
    pre[0] = 0;
    f1(i,1,n)
    {
    	pre[i] = pre[i-1] + a[i-1];
    }

    int ans = 0;
    if(problem == 0)
    {
    	ans += pre[n];
    }
    else
    {
	    f1(i,1,problem)
	    {
	    	if((i-1)*(d+1)+1 > n) break;
	    	if(problem > (i-1)*(d+1)+1) continue;
	    	int cur = pre[i];
	    	int lim = problem + n-((i-1)*(d+1)+1);
	    	cur += pre[lim] - pre[problem];
	    	ans = max(ans, cur);
	    }
	}

    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;

/* // Ordered Set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)
// int ncr(int n,int r) {return (fact[n]*modInv(fact[r]))%mod*modInv(fact[n-r])%mod;}
// int modInv(int i) {return binExp(i,mod-2);}

signed main()
{
    fast

    #ifndef ONLINE_JUDGE
        freopen("inputf.in","r",stdin);
        freopen("outputf.in","w",stdout);
    #endif

    int n,d,m;
    cin>>n>>d>>m;

    vll problem;
    vll normal;
    int x;
    f0(i,0,n)
    {
    	cin>>x;
    	if(x > m) problem.pb(x);
    	else normal.pb(x);
    }
    sort(all(problem), greater<int>());
    sort(all(normal), greater<int>());

    int ans = 0;
    if(problem.size() == 0)
    {
    	for(auto x : normal) ans += x;
    }
    else
    {
	    int prep[problem.size()+1];
	    int pren[normal.size()+1];

	    prep[0] = pren[0] = 0;
	    f1(i,1,problem.size())
	    {
	    	prep[i] = prep[i-1] + problem[i-1];
	    }
	    f1(i,1,normal.size())
	    {
	    	pren[i] = pren[i-1] + normal[i-1];
	    }
	    f1(i,normal.size()+1,problem.size())
	    {
	    	pren[i] = pren[normal.size()];
	    }

	    f1(i,(problem.size()+d)/(1+d),problem.size())
	    {
	    	if((i-1)*(d+1)+1 <= n)
	    	{
		    	// cout<<i<<' '<<(i-1)*(d+1)+1<<'\n';
		    	ans = max(ans, prep[i] + pren[n - ((i-1)*(d+1)+1)]);
	    	}
	    }

	}

    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;

/* // Ordered Set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)
// int ncr(int n,int r) {return (fact[n]*modInv(fact[r]))%mod*modInv(fact[n-r])%mod;}
// int modInv(int i) {return binExp(i,mod-2);}

signed main()
{
    fast

    #ifndef ONLINE_JUDGE
        freopen("inputf.in","r",stdin);
        freopen("outputf.in","w",stdout);
    #endif

    int n,d,m;
    cin>>n>>d>>m;

    vll problem;
    vll normal;
    int x;
    f0(i,0,n)
    {
    	cin>>x;
    	if(x > m) problem.pb(x);
    	else normal.pb(x);
    }
    sort(all(problem), greater<int>());
    sort(all(normal), greater<int>());

    int ans = 0;
    if(problem.size() == 0)
    {
    	for(auto x : normal) ans += x;
    }
    else
    {
	    int prep[problem.size()+1];
	    int pren[normal.size()+1];

	    prep[0] = pren[0] = 0;
	    f1(i,1,problem.size())
	    {
	    	prep[i] = prep[i-1] + problem[i-1];
	    }
	    f1(i,1,normal.size())
	    {
	    	pren[i] = pren[i-1] + normal[i-1];
	    }

	    f1(i,1,problem.size())
	    {
	    	if((i-1)*(d+1)+1 < problem.size()) continue;
	    	if((i-1)*(d+1)+1 > n) break;
	    	// cout<<i<<' '<<(i-1)*(d+1)+1<<'\n';
	    	ans = max(ans, prep[i] + pren[n - ((i-1)*(d+1)+1)]);
	    }

	}

    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;

/* // Ordered Set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)
// int ncr(int n,int r) {return (fact[n]*modInv(fact[r]))%mod*modInv(fact[n-r])%mod;}
// int modInv(int i) {return binExp(i,mod-2);}

signed main()
{
    fast

    #ifndef ONLINE_JUDGE
        freopen("inputf.in","r",stdin);
        freopen("outputf.in","w",stdout);
    #endif

    int n,d,m;
    cin>>n>>d>>m;

    vi a(n);
    int problem = 0;
    f0(i,0,n)
    {
    	cin>>a[i];
    	if(a[i] > m) problem++;
    }
    sort(all(a), greater<int>());

    int pre[n+1];
    pre[0] = 0;
    f1(i,1,n)
    {
    	pre[i] = pre[i-1] + a[i-1];
    }

    int ans = 0;
    f1(i,1,problem)
    {
    	if((i-1)*(d+1)+1 > n) break;
    	if(problem > (i-1)*(d+1)+1) continue;
    	int cur = pre[i];
    	int lim = problem + n-((i-1)*(d+1)+1);
    	cur += pre[lim] - pre[problem];
    	ans = max(ans, cur);
    }

    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;

/* // Ordered Set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
// #define int long long
#define fi first
#define se second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)
// int ncr(int n,int r) {return (fact[n]*modInv(fact[r]))%mod*modInv(fact[n-r])%mod;}
// int modInv(int i) {return binExp(i,mod-2);}

signed main()
{
    fast

    #ifndef ONLINE_JUDGE
        freopen("inputf.in","r",stdin);
        freopen("outputf.in","w",stdout);
    #endif

    int n,d,m;
    cin>>n>>d>>m;

    vi a(n);
    int problem = 0;
    f0(i,0,n)
    {
    	cin>>a[i];
    	if(a[i] > m) problem++;
    }
    sort(all(a), greater<int>());

    int pre[n+1];
    pre[0] = 0;
    f1(i,1,n)
    {
    	pre[i] = pre[i-1] + a[i-1];
    }

    int ans = 0;
    f1(i,1,problem)
    {
    	if((i-1)*(d+1)+1 > n) break;
    	if(problem > (i-1)*(d+1)+1) continue;
    	int cur = pre[i];
    	int lim = problem + n-((i-1)*(d+1)+1);
    	cur += pre[lim] - pre[problem];
    	ans = max(ans, cur);
    }

    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;

/* // Ordered Set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)
// int ncr(int n,int r) {return (fact[n]*modInv(fact[r]))%mod*modInv(fact[n-r])%mod;}
// int modInv(int i) {return binExp(i,mod-2);}

signed main()
{
    fast

    #ifndef ONLINE_JUDGE
        freopen("inputf.in","r",stdin);
        freopen("outputf.in","w",stdout);
    #endif

    int n,d,m;
    cin>>n>>d>>m;

    vi problem;
    vi normal;
    int x;
    f0(i,0,n)
    {
    	cin>>x;
    	if(x > m) problem.pb(x);
    	else normal.pb(x);
    }
    sort(all(problem), greater<int>());
    sort(all(normal), greater<int>());

    int ans = 0;
    if(problem.size() == 0)
    {
    	for(auto x : normal) ans += x;
    }
    else
    {
	    int prep[problem.size()+1];
	    int pren[normal.size()+1];

	    prep[0] = pren[0] = 0;
	    f1(i,1,problem.size())
	    {
	    	prep[i] = prep[i-1] + problem[i-1];
	    }
	    f1(i,1,normal.size())
	    {
	    	pren[i] = pren[i-1] + normal[i-1];
	    }

	    for(auto x : prep) cout<<x<<' '; cout<<'\n';
	    for(auto x : pren) cout<<x<<' '; cout<<'\n';

	    f1(i,1,problem.size())
	    {
	    	if((i-1)*(d+1)+1 < problem.size()) continue;
	    	if((i-1)*(d+1)+1 > n) break;
	    	// cout<<i<<' '<<(i-1)*(d+1)+1<<'\n';
	    	ans = max(ans, prep[i] + pren[n - ((i-1)*(d+1)+1)]);
	    }

	}

    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;

/* // Ordered Set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)
// int ncr(int n,int r) {return (fact[n]*modInv(fact[r]))%mod*modInv(fact[n-r])%mod;}
// int modInv(int i) {return binExp(i,mod-2);}

signed main()
{
    fast

    #ifndef ONLINE_JUDGE
        freopen("inputf.in","r",stdin);
        freopen("outputf.in","w",stdout);
    #endif

    int n,d,m;
    cin>>n>>d>>m;

    vll problem;
    vll normal;
    int x;
    f0(i,0,n)
    {
    	cin>>x;
    	if(x > m) problem.pb(x);
    	else normal.pb(x);
    }
    sort(all(problem), greater<int>());
    sort(all(normal), greater<int>());

    int ans = 0;
    if(problem.size() == 0)
    {
    	for(auto x : normal) ans += x;
    }
    else
    {
	    int prep[problem.size()+1];
	    int pren[normal.size()+1];

	    prep[0] = pren[0] = 0;
	    f1(i,1,problem.size())
	    {
	    	prep[i] = prep[i-1] + problem[i-1];
	    }
	    f1(i,1,normal.size())
	    {
	    	pren[i] = pren[i-1] + normal[i-1];
	    }
	    f1(i,normal.size()+1,n)
	    {
	    	pren[i] = pren[normal.size()];
	    }

	    f1(i,(problem.size()+d)/(1+d),problem.size())
	    {
	    	if((i-1)*(d+1)+1 <= n)
	    	{
		    	// cout<<i<<' '<<(i-1)*(d+1)+1<<'\n';
		    	ans = max(ans, prep[i] + pren[n - ((i-1)*(d+1)+1)]);
	    	}
	    }

	}

    cout<<ans;
}


#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define pb(x)           push_back(x)
#define mkp(x,y)        make_pair(x,y)
#define L               length()
#define int             long long
#define bs              binary_search
#define mod             1e9+7
#define IOS             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(v)          v.begin(),v.end()
#define mem0(a)         memset(a,0,sizeof(a))
#define mem1(a)         memset(a,-1,sizeof(a))
#define F               first
#define S               second
#define pii             pair<int,int>
#define vi              vector<int>
#define vs              size()
#define gcd(a,b)        __ gcd(a,b)
#define endl            '\n'
#define atoi            stoi
#define elasped_time    1.0 * clock() / CLOCKS_PER_SEC
#define si              set <int>
#define vpii            vector < pair <int,int> >
#define memf(a)         memset(a,false,sizeof(a))
#define memt(a)         memset(a,true,sizeof(a))
#define xxx             998244353
#define pi              3.141592653589
#define ninf            INT_MIN
#define inf             INT_MAX
#define sz(v)           ((int)(v).size())
#define rep(i,a,b)      for(int i=a;i<=b;i++)
int max(int a,int b){if(a>b){return a;}else{return b;}}
int min(int a,int b){if(a<b){return a;}else{return b;}}
int power(int b,int e)
{
    if(e==0)
    return 1;
    if(e%2)
    return ((b*power((b)*(b),(e-1)/2)));
    else
    return power((b)*(b),e/2);
}
int modpower(int b,int e,int q)
{
    int MOD=q;
    if(e==0)
    return 1;
    if(e%2)
    return ((b%MOD)*modpower((b%MOD)*(b%MOD),(e-1)/2,q))%MOD;
    else
    return modpower((b%MOD)*(b%MOD),e/2,q)%MOD;
}
void dpv(vi v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
void dpv(vpii v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i].F<<" "<<v[i].S<<endl;
    }
}
void dpv(set <int> v)
{
    for(auto i:v)
    {
        cout<<i<<" ";
    }
    cout<<endl;
}
//////////////////////**TREE MOVES STARTS**//////////////////////////////
///// **TREE MOVES ENDS**////////////////////////////

////*SOLUTION TO THE QUESTION STARTS HERE*///////
//ool vis[105][105];
int a[100010],b[100010];
int n,d,m,l,k;
void solve(int a[],int n)
{
    sort(a + 1, a + n + 1);
	reverse(a + 1, a + n + 1);
    for(int i=1;i<=n;i++)
    {
        a[i]+=a[i-1];
    }
}
void oblivious()
{
    scanf("%lld %lld %lld", &n, &d, &m);
	for (int i = 0, x; i < n; i++) {
		scanf("%lld", &x);
		if (x > m) a[++k] = x;
		else b[++l] = x;
	}
	if (k == 0) {
		int s = 0;
		rep(i, 1, n) s += b[i];
		printf("%lld\n", s);
		exit(0);
	}
	solve(a, k);
	solve(b, l);
	fill(b + l + 1, b + n + 1, b[l]);
	int res = 0;
	rep(i, (k + d) / (1 + d), k) if (1ll * (i - 1) * (d + 1) + 1 <= n) {
		res = max(res, a[i] + b[n - 1ll * (i - 1) * (d + 1) - 1]);
	}
	printf("%lld\n", res);
	return ;

}
signed main()
{
    IOS;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    int t=1;
    //cin>>t;
    while(t--)
    {
        oblivious();
    }
    return 0;
}


#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define pb(x)           push_back(x)
#define mkp(x,y)        make_pair(x,y)
#define L               length()
#define int             long long
#define bs              binary_search
#define mod             1e9+7
#define IOS             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(v)          v.begin(),v.end()
#define mem0(a)         memset(a,0,sizeof(a))
#define mem1(a)         memset(a,-1,sizeof(a))
#define F               first
#define S               second
#define pii             pair<int,int>
#define vi              vector<int>
#define vs              size()
#define gcd(a,b)        __ gcd(a,b)
#define endl            '\n'
#define atoi            stoi
#define elasped_time    1.0 * clock() / CLOCKS_PER_SEC
#define si              set <int>
#define vpii            vector < pair <int,int> >
#define memf(a)         memset(a,false,sizeof(a))
#define memt(a)         memset(a,true,sizeof(a))
#define xxx             998244353
#define pi              3.141592653589
#define ninf            INT_MIN
#define inf             INT_MAX
#define sz(v)           ((int)(v).size())
int max(int a,int b){if(a>b){return a;}else{return b;}}
int min(int a,int b){if(a<b){return a;}else{return b;}}
int power(int b,int e)
{
    if(e==0)
    return 1;
    if(e%2)
    return ((b*power((b)*(b),(e-1)/2)));
    else
    return power((b)*(b),e/2);
}
int modpower(int b,int e,int q)
{
    int MOD=q;
    if(e==0)
    return 1;
    if(e%2)
    return ((b%MOD)*modpower((b%MOD)*(b%MOD),(e-1)/2,q))%MOD;
    else
    return modpower((b%MOD)*(b%MOD),e/2,q)%MOD;
}
void dpv(vi v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
void dpv(vpii v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i].F<<" "<<v[i].S<<endl;
    }
}
void dpv(set <int> v)
{
    for(auto i:v)
    {
        cout<<i<<" ";
    }
    cout<<endl;
}
//////////////////////**TREE MOVES STARTS**//////////////////////////////
///// **TREE MOVES ENDS**////////////////////////////

////*SOLUTION TO THE QUESTION STARTS HERE*///////
//ool vis[105][105];
bool gr(int a,int b)
{
    return (a>b);
}
int a[100005],b[100005];
int n,d,m,l,k;
void turntoprefsum(int a[],int n)
{
    sort(a + 1, a + n + 1);
	reverse(a + 1, a + n + 1);
    for(int i=1;i<=n;i++)
    {
        a[i]+=a[i-1];
    }
}
void oblivious()
{
    mem0(a);
    mem0(b);
    cin>>n>>d>>m;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(x>m)
        {
            a[++l]=x;
        }
        else
        {
            b[++k]=x;
        }
    }
    int ans=0;
    turntoprefsum(a,l);
    turntoprefsum(b,k);
    fill(b+k+1,b+n+1,b[k]);
    if(l==0)
    {
        for(int j=1;j<=n;j++)
        {
            ans+=b[j];
        }
    }
    else
    {
        for(int i=(l+d)/(1+d);i<=l;i++)
        {
            int f1=(i-1)*(d+1)+1;
            int f2=n-f1;
            if(f1<=n)
            {
                ans=max(ans,a[i]+b[f2]);
            }
        }
    }
    cout<<ans<<endl;
}
signed main()
{
    IOS;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    int t=1;
    //cin>>t;
    while(t--)
    {
        oblivious();
    }
    return 0;
}


#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define pb(x)           push_back(x)
#define mkp(x,y)        make_pair(x,y)
#define L               length()
#define int             long long
#define bs              binary_search
#define mod             1e9+7
#define IOS             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(v)          v.begin(),v.end()
#define mem0(a)         memset(a,0,sizeof(a))
#define mem1(a)         memset(a,-1,sizeof(a))
#define F               first
#define S               second
#define pii             pair<int,int>
#define vi              vector<int>
#define vs              size()
#define gcd(a,b)        __ gcd(a,b)
#define endl            '\n'
#define atoi            stoi
#define elasped_time    1.0 * clock() / CLOCKS_PER_SEC
#define si              set <int>
#define vpii            vector < pair <int,int> >
#define memf(a)         memset(a,false,sizeof(a))
#define memt(a)         memset(a,true,sizeof(a))
#define xxx             998244353
#define pi              3.141592653589
#define ninf            INT_MIN
#define inf             INT_MAX
#define sz(v)           ((int)(v).size())
int max(int a,int b){if(a>b){return a;}else{return b;}}
int min(int a,int b){if(a<b){return a;}else{return b;}}
int power(int b,int e)
{
    if(e==0)
    return 1;
    if(e%2)
    return ((b*power((b)*(b),(e-1)/2)));
    else
    return power((b)*(b),e/2);
}
int modpower(int b,int e,int q)
{
    int MOD=q;
    if(e==0)
    return 1;
    if(e%2)
    return ((b%MOD)*modpower((b%MOD)*(b%MOD),(e-1)/2,q))%MOD;
    else
    return modpower((b%MOD)*(b%MOD),e/2,q)%MOD;
}
void dpv(vi v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
void dpv(vpii v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i].F<<" "<<v[i].S<<endl;
    }
}
void dpv(set <int> v)
{
    for(auto i:v)
    {
        cout<<i<<" ";
    }
    cout<<endl;
}
//////////////////////**TREE MOVES STARTS**//////////////////////////////
///// **TREE MOVES ENDS**////////////////////////////

////*SOLUTION TO THE QUESTION STARTS HERE*///////
//ool vis[105][105];
bool gr(int a,int b)
{
    return (a>b);
}
int a[100010],b[100010];
int n,d,m,l,k;
void turntoprefsum(int a[],int n)
{
    sort(a + 1, a + n + 1);
	reverse(a + 1, a + n + 1);
    for(int i=1;i<=n;i++)
    {
        a[i]+=a[i-1];
    }
}
void oblivious()
{
    mem0(a);
    mem0(b);
    cin>>n>>d>>m;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(x>m)
        {
            a[++l]=x;
        }
        else
        {
            b[++k]=x;
        }
    }
    int ans=0;
    turntoprefsum(a,l);
    turntoprefsum(b,k);
    fill(b+k+1,b+n+1,b[k]);
    if(l==0)
    {
        for(int j=1;j<=n;j++)
        {
            ans+=b[j];
        }
    }
    else
    {
        for(int i=(l+d)/(1+d);i<=l;i++)
        {
            int f1=(i-1)*(d+1)+1;
            int f2=n-f1;
            if(f1<=n)
            {
                ans=max(ans,a[i]+b[f2]);
            }
        }
    }
    cout<<ans<<endl;
}
signed main()
{
    IOS;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    int t=1;
    //cin>>t;
    while(t--)
    {
        oblivious();
    }
    return 0;
}


#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define pb(x)           push_back(x)
#define mkp(x,y)        make_pair(x,y)
#define L               length()
#define int             long long
#define bs              binary_search
#define mod             1e9+7
#define IOS             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(v)          v.begin(),v.end()
#define mem0(a)         memset(a,0,sizeof(a))
#define mem1(a)         memset(a,-1,sizeof(a))
#define F               first
#define S               second
#define pii             pair<int,int>
#define vi              vector<int>
#define vs              size()
#define gcd(a,b)        __ gcd(a,b)
#define endl            '\n'
#define atoi            stoi
#define elasped_time    1.0 * clock() / CLOCKS_PER_SEC
#define si              set <int>
#define vpii            vector < pair <int,int> >
#define memf(a)         memset(a,false,sizeof(a))
#define memt(a)         memset(a,true,sizeof(a))
#define xxx             998244353
#define pi              3.141592653589
#define ninf            INT_MIN
#define inf             INT_MAX
#define sz(v)           ((int)(v).size())
int max(int a,int b){if(a>b){return a;}else{return b;}}
int min(int a,int b){if(a<b){return a;}else{return b;}}
int power(int b,int e)
{
    if(e==0)
    return 1;
    if(e%2)
    return ((b*power((b)*(b),(e-1)/2)));
    else
    return power((b)*(b),e/2);
}
int modpower(int b,int e,int q)
{
    int MOD=q;
    if(e==0)
    return 1;
    if(e%2)
    return ((b%MOD)*modpower((b%MOD)*(b%MOD),(e-1)/2,q))%MOD;
    else
    return modpower((b%MOD)*(b%MOD),e/2,q)%MOD;
}
void dpv(vi v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
void dpv(vpii v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i].F<<" "<<v[i].S<<endl;
    }
}
void dpv(set <int> v)
{
    for(auto i:v)
    {
        cout<<i<<" ";
    }
    cout<<endl;
}
//////////////////////**TREE MOVES STARTS**//////////////////////////////
///// **TREE MOVES ENDS**////////////////////////////

////*SOLUTION TO THE QUESTION STARTS HERE*///////
//ool vis[105][105];
bool gr(int a,int b)
{
    return (a>b);
}
void oblivious()
{
    int n,d,m;
    cin>>n>>d>>m;
    vi a,b;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(x>m)
        {
            a.pb(x);
        }
        else
        {
            b.pb(x);
        }
    }
    int ans=0;
    int z=(n+d)/(d+1);
    sort(all(a),gr);
    sort(all(b),gr);
    if(sz(a)==0)
    {
        for(int j=0;j<n;j++)
        {
            ans+=b[j];
        }
    }
    else
    {
        for(int i=(sz(a)+d)/(1+d);i<=sz(a);i++)
        {
            int f1=(i-1)*(d+1)+1;
            int f2=n-f1;
            if(f1<=n)
            {
                int s1=0;
                for(int j=0;j<i;j++)
                {
                    s1+=a[j];
                }
                for(int j=0;j<f2;j++)
                {
                    s1+=b[j];
                }
                ans=max(ans,s1);
            }
        }
    }
    cout<<ans<<endl;
}
signed main()
{
    IOS;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    int t=1;
    //cin>>t;
    while(t--)
    {
        oblivious();
    }
    return 0;
}


#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define pb(x)           push_back(x)
#define mkp(x,y)        make_pair(x,y)
#define L               length()
#define int             long long
#define bs              binary_search
#define mod             1e9+7
#define IOS             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(v)          v.begin(),v.end()
#define mem0(a)         memset(a,0,sizeof(a))
#define mem1(a)         memset(a,-1,sizeof(a))
#define F               first
#define S               second
#define pii             pair<int,int>
#define vi              vector<int>
#define vs              size()
#define gcd(a,b)        __ gcd(a,b)
#define endl            '\n'
#define atoi            stoi
#define elasped_time    1.0 * clock() / CLOCKS_PER_SEC
#define si              set <int>
#define vpii            vector < pair <int,int> >
#define memf(a)         memset(a,false,sizeof(a))
#define memt(a)         memset(a,true,sizeof(a))
#define xxx             998244353
#define pi              3.141592653589
#define ninf            INT_MIN
#define inf             INT_MAX
#define sz(v)           ((int)(v).size())
int max(int a,int b){if(a>b){return a;}else{return b;}}
int min(int a,int b){if(a<b){return a;}else{return b;}}
int power(int b,int e)
{
    if(e==0)
    return 1;
    if(e%2)
    return ((b*power((b)*(b),(e-1)/2)));
    else
    return power((b)*(b),e/2);
}
int modpower(int b,int e,int q)
{
    int MOD=q;
    if(e==0)
    return 1;
    if(e%2)
    return ((b%MOD)*modpower((b%MOD)*(b%MOD),(e-1)/2,q))%MOD;
    else
    return modpower((b%MOD)*(b%MOD),e/2,q)%MOD;
}
void dpv(vi v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
void dpv(vpii v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i].F<<" "<<v[i].S<<endl;
    }
}
void dpv(set <int> v)
{
    for(auto i:v)
    {
        cout<<i<<" ";
    }
    cout<<endl;
}
//////////////////////**TREE MOVES STARTS**//////////////////////////////
///// **TREE MOVES ENDS**////////////////////////////

////*SOLUTION TO THE QUESTION STARTS HERE*///////
//ool vis[105][105];
bool gr(int a,int b)
{
    return (a>b);
}
int a[100005],b[100005];
int n,d,m;
void turntoprefsum(int a[],int k)
{
    sort(a + 1, a + k + 1);
	reverse(a + 1, a + k + 1);
    for(int i=1;i<=k;i++)
    {
        a[i]+=a[i-1];
    }
}
void oblivious()
{
    mem0(a);
    mem0(b);
    cin>>n>>d>>m;
    int l=0,k=0;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(x>m)
        {
            a[++l]=x;
        }
        else
        {
            b[++k]=x;
        }
    }
    int ans=0;
    turntoprefsum(a,l);
    turntoprefsum(b,k);
    fill(b+k+1,b+n+1,b[k]);
    if(l==0)
    {
        for(int j=1;j<=n;j++)
        {
            ans+=b[j];
        }
    }
    else
    {
        for(int i=(l+d)/(1+d);i<=l;i++)
        {
            int f1=(i-1)*(d+1)+1;
            int f2=n-f1;
            if(f1<=n)
            {
                ans=max(ans,a[i]+b[f2]);
            }
        }
    }
    cout<<ans<<endl;
}
signed main()
{
    IOS;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    int t=1;
    //cin>>t;
    while(t--)
    {
        oblivious();
    }
    return 0;
}


#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define pb(x)           push_back(x)
#define mkp(x,y)        make_pair(x,y)
#define L               length()
#define int             long long
#define bs              binary_search
#define mod             1e9+7
#define IOS             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(v)          v.begin(),v.end()
#define mem0(a)         memset(a,0,sizeof(a))
#define mem1(a)         memset(a,-1,sizeof(a))
#define F               first
#define S               second
#define pii             pair<int,int>
#define vi              vector<int>
#define vs              size()
#define gcd(a,b)        __ gcd(a,b)
#define endl            '\n'
#define atoi            stoi
#define elasped_time    1.0 * clock() / CLOCKS_PER_SEC
#define si              set <int>
#define vpii            vector < pair <int,int> >
#define memf(a)         memset(a,false,sizeof(a))
#define memt(a)         memset(a,true,sizeof(a))
#define xxx             998244353
#define pi              3.141592653589
#define ninf            INT_MIN
#define inf             INT_MAX
#define sz(v)           ((int)(v).size())
int max(int a,int b){if(a>b){return a;}else{return b;}}
int min(int a,int b){if(a<b){return a;}else{return b;}}
int power(int b,int e)
{
    if(e==0)
    return 1;
    if(e%2)
    return ((b*power((b)*(b),(e-1)/2)));
    else
    return power((b)*(b),e/2);
}
int modpower(int b,int e,int q)
{
    int MOD=q;
    if(e==0)
    return 1;
    if(e%2)
    return ((b%MOD)*modpower((b%MOD)*(b%MOD),(e-1)/2,q))%MOD;
    else
    return modpower((b%MOD)*(b%MOD),e/2,q)%MOD;
}
void dpv(vi v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
void dpv(vpii v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i].F<<" "<<v[i].S<<endl;
    }
}
void dpv(set <int> v)
{
    for(auto i:v)
    {
        cout<<i<<" ";
    }
    cout<<endl;
}
//////////////////////**TREE MOVES STARTS**//////////////////////////////
///// **TREE MOVES ENDS**////////////////////////////

////*SOLUTION TO THE QUESTION STARTS HERE*///////
//ool vis[105][105];
bool gr(int a,int b)
{
    return (a>b);
}
void oblivious()
{
    int n,d,m;
    cin>>n>>d>>m;
    vi a,b;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(x>m)
        {
            a.pb(x);
        }
        else
        {
            b.pb(x);
        }
    }
    int ans=0;
    int z=(n+d)/(d+1);
    sort(all(a),gr);
    sort(all(b),gr);
    if(sz(a)==0)
    {
        for(int j=0;j<n;j++)
        {
            ans+=b[j];
        }
    }
    else
    {
        for(int i=1;i<=z;i++)
        {
            int f1=(i-1)*(d+1)+1;
            int f2=n-f1;
            if(sz(a)>=i&&sz(b)>=f2&&(f1+f2==n&&f1>=0&&f2>=0))
            {
                int s1=0;
                for(int j=0;j<i;j++)
                {
                    s1+=a[j];
                }
                for(int j=0;j<f2;j++)
                {
                    s1+=b[j];
                }
                ans=max(ans,s1);
            }
        }
    }
    cout<<ans<<endl;
}
signed main()
{
    IOS;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    int t=1;
    //cin>>t;
    while(t--)
    {
        oblivious();
    }
    return 0;
}


#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define pb(x)           push_back(x)
#define mkp(x,y)        make_pair(x,y)
#define L               length()
#define int             long long
#define bs              binary_search
#define mod             1e9+7
#define IOS             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(v)          v.begin(),v.end()
#define mem0(a)         memset(a,0,sizeof(a))
#define mem1(a)         memset(a,-1,sizeof(a))
#define F               first
#define S               second
#define pii             pair<int,int>
#define vi              vector<int>
#define vs              size()
#define gcd(a,b)        __ gcd(a,b)
#define endl            '\n'
#define atoi            stoi
#define elasped_time    1.0 * clock() / CLOCKS_PER_SEC
#define si              set <int>
#define vpii            vector < pair <int,int> >
#define memf(a)         memset(a,false,sizeof(a))
#define memt(a)         memset(a,true,sizeof(a))
#define xxx             998244353
#define pi              3.141592653589
#define ninf            INT_MIN
#define inf             INT_MAX
#define sz(v)           ((int)(v).size())
int max(int a,int b){if(a>b){return a;}else{return b;}}
int min(int a,int b){if(a<b){return a;}else{return b;}}
int power(int b,int e)
{
    if(e==0)
    return 1;
    if(e%2)
    return ((b*power((b)*(b),(e-1)/2)));
    else
    return power((b)*(b),e/2);
}
int modpower(int b,int e,int q)
{
    int MOD=q;
    if(e==0)
    return 1;
    if(e%2)
    return ((b%MOD)*modpower((b%MOD)*(b%MOD),(e-1)/2,q))%MOD;
    else
    return modpower((b%MOD)*(b%MOD),e/2,q)%MOD;
}
void dpv(vi v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
void dpv(vpii v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i].F<<" "<<v[i].S<<endl;
    }
}
void dpv(set <int> v)
{
    for(auto i:v)
    {
        cout<<i<<" ";
    }
    cout<<endl;
}
//////////////////////**TREE MOVES STARTS**//////////////////////////////
///// **TREE MOVES ENDS**////////////////////////////

////*SOLUTION TO THE QUESTION STARTS HERE*///////
//ool vis[105][105];
bool gr(int a,int b)
{
    return (a>b);
}
int a[100005],b[100005];
int n,d,m;
void turntoprefsum(int a[],int k)
{
    sort(a + 1, a + k + 1);
	reverse(a + 1, a + k + 1);
    for(int i=1;i<=k;i++)
    {
        a[i]+=a[i-1];
    }
}
void oblivious()
{
    cin>>n>>d>>m;
    int l=0,k=0;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(x>m)
        {
            a[++l]=x;
        }
        else
        {
            b[++k]=x;
        }
    }
    int ans=0;
    turntoprefsum(a,l);
    turntoprefsum(b,k);
    fill(b+k+1,b+n+1,b[k]);
    if(l==0)
    {
        for(int j=1;j<=n;j++)
        {
            ans+=b[j];
        }
    }
    else
    {
        for(int i=(l+d)/(1+d);i<=l;i++)
        {
            int f1=(i-1)*(d+1)+1;
            int f2=n-f1;
            if(f1<=n)
            {
                ans=max(ans,a[i]+b[f2]);
            }
        }
    }
    cout<<ans<<endl;
}
signed main()
{
    IOS;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    int t=1;
    //cin>>t;
    while(t--)
    {
        oblivious();
    }
    return 0;
}


#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define pb(x)           push_back(x)
#define mkp(x,y)        make_pair(x,y)
#define L               length()
#define int             long long
#define bs              binary_search
#define mod             1e9+7
#define IOS             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(v)          v.begin(),v.end()
#define mem0(a)         memset(a,0,sizeof(a))
#define mem1(a)         memset(a,-1,sizeof(a))
#define F               first
#define S               second
#define pii             pair<int,int>
#define vi              vector<int>
#define vs              size()
#define gcd(a,b)        __ gcd(a,b)
#define endl            '\n'
#define atoi            stoi
#define elasped_time    1.0 * clock() / CLOCKS_PER_SEC
#define si              set <int>
#define vpii            vector < pair <int,int> >
#define memf(a)         memset(a,false,sizeof(a))
#define memt(a)         memset(a,true,sizeof(a))
#define xxx             998244353
#define pi              3.141592653589
#define ninf            INT_MIN
#define inf             INT_MAX
#define sz(v)           ((int)(v).size())
int max(int a,int b){if(a>b){return a;}else{return b;}}
int min(int a,int b){if(a<b){return a;}else{return b;}}
int power(int b,int e)
{
    if(e==0)
    return 1;
    if(e%2)
    return ((b*power((b)*(b),(e-1)/2)));
    else
    return power((b)*(b),e/2);
}
int modpower(int b,int e,int q)
{
    int MOD=q;
    if(e==0)
    return 1;
    if(e%2)
    return ((b%MOD)*modpower((b%MOD)*(b%MOD),(e-1)/2,q))%MOD;
    else
    return modpower((b%MOD)*(b%MOD),e/2,q)%MOD;
}
void dpv(vi v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
void dpv(vpii v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i].F<<" "<<v[i].S<<endl;
    }
}
void dpv(set <int> v)
{
    for(auto i:v)
    {
        cout<<i<<" ";
    }
    cout<<endl;
}
//////////////////////**TREE MOVES STARTS**//////////////////////////////
///// **TREE MOVES ENDS**////////////////////////////

////*SOLUTION TO THE QUESTION STARTS HERE*///////
//ool vis[105][105];
bool gr(int a,int b)
{
    return (a>b);
}
void oblivious()
{
    int n,d,m;
    cin>>n>>d>>m;
    vi a,b;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(x>m)
        {
            a.pb(x);
        }
        else
        {
            b.pb(x);
        }
    }
    int ans=0;
    int z=(n+d)/(d+1);
    sort(all(a),gr);
    sort(all(b),gr);
    if(sz(a)==0)
    {
        for(int j=0;j<n;j++)
        {
            ans+=b[j];
        }
    }
    else
    {
        for(int i=1;i<=z+1;i++)
        {
            int f1=(i-1)*(d+1)+1;
            int f2=n-f1;
            if(sz(a)>=i&&sz(b)>=f2&&(f1>=0&&f2>=0))
            {
                int s1=0;
                for(int j=0;j<i;j++)
                {
                    s1+=a[j];
                }
                for(int j=0;j<f2;j++)
                {
                    s1+=b[j];
                }
                ans=max(ans,s1);
            }
        }
    }
    cout<<ans<<endl;
}
signed main()
{
    IOS;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    int t=1;
    //cin>>t;
    while(t--)
    {
        oblivious();
    }
    return 0;
}


#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define pb(x)           push_back(x)
#define mkp(x,y)        make_pair(x,y)
#define L               length()
#define int             long long
#define bs              binary_search
#define mod             1e9+7
#define IOS             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(v)          v.begin(),v.end()
#define mem0(a)         memset(a,0,sizeof(a))
#define mem1(a)         memset(a,-1,sizeof(a))
#define F               first
#define S               second
#define pii             pair<int,int>
#define vi              vector<int>
#define vs              size()
#define gcd(a,b)        __ gcd(a,b)
#define endl            '\n'
#define atoi            stoi
#define elasped_time    1.0 * clock() / CLOCKS_PER_SEC
#define si              set <int>
#define vpii            vector < pair <int,int> >
#define memf(a)         memset(a,false,sizeof(a))
#define memt(a)         memset(a,true,sizeof(a))
#define xxx             998244353
#define pi              3.141592653589
#define ninf            INT_MIN
#define inf             INT_MAX
#define sz(v)           ((int)(v).size())
int max(int a,int b){if(a>b){return a;}else{return b;}}
int min(int a,int b){if(a<b){return a;}else{return b;}}
int power(int b,int e)
{
    if(e==0)
    return 1;
    if(e%2)
    return ((b*power((b)*(b),(e-1)/2)));
    else
    return power((b)*(b),e/2);
}
int modpower(int b,int e,int q)
{
    int MOD=q;
    if(e==0)
    return 1;
    if(e%2)
    return ((b%MOD)*modpower((b%MOD)*(b%MOD),(e-1)/2,q))%MOD;
    else
    return modpower((b%MOD)*(b%MOD),e/2,q)%MOD;
}
void dpv(vi v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
void dpv(vpii v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i].F<<" "<<v[i].S<<endl;
    }
}
void dpv(set <int> v)
{
    for(auto i:v)
    {
        cout<<i<<" ";
    }
    cout<<endl;
}
//////////////////////**TREE MOVES STARTS**//////////////////////////////
///// **TREE MOVES ENDS**////////////////////////////

////*SOLUTION TO THE QUESTION STARTS HERE*///////
//ool vis[105][105];
bool gr(int a,int b)
{
    return (a>b);
}
int a[100005],b[100005];
int n,d,m;
void turntoprefsum(int a[],int k)
{
    sort(a + 1, a + n + 1);
	reverse(a + 1, a + n + 1);
    for(int i=1;i<=k;i++)
    {
        a[i]+=a[i-1];
    }
}
void oblivious()
{
    cin>>n>>d>>m;
    int l=0,k=0;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(x>m)
        {
            a[++l]=x;
        }
        else
        {
            b[++k]=x;
        }
    }
    int ans=0;
    turntoprefsum(a,l);
    turntoprefsum(b,k);
    fill(b+k+1,b+n+1,b[k]);
    if(l==0)
    {
        for(int j=1;j<=n;j++)
        {
            ans+=b[j];
        }
    }
    else
    {
        for(int i=(l+d)/(1+d);i<=l;i++)
        {
            int f1=(i-1)*(d+1)+1;
            int f2=n-f1;
            if(f1<=n)
            {
                ans=max(ans,a[i]+b[f2]);
            }
        }
    }
    cout<<ans<<endl;
}
signed main()
{
    IOS;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    int t=1;
    //cin>>t;
    while(t--)
    {
        oblivious();
    }
    return 0;
}


#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define pb(x)           push_back(x)
#define mkp(x,y)        make_pair(x,y)
#define L               length()
#define int             long long
#define bs              binary_search
#define mod             1e9+7
#define IOS             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(v)          v.begin(),v.end()
#define mem0(a)         memset(a,0,sizeof(a))
#define mem1(a)         memset(a,-1,sizeof(a))
#define F               first
#define S               second
#define pii             pair<int,int>
#define vi              vector<int>
#define vs              size()
#define gcd(a,b)        __ gcd(a,b)
#define endl            '\n'
#define atoi            stoi
#define elasped_time    1.0 * clock() / CLOCKS_PER_SEC
#define si              set <int>
#define vpii            vector < pair <int,int> >
#define memf(a)         memset(a,false,sizeof(a))
#define memt(a)         memset(a,true,sizeof(a))
#define xxx             998244353
#define pi              3.141592653589
#define ninf            INT_MIN
#define inf             INT_MAX
#define sz(v)           ((int)(v).size())
int max(int a,int b){if(a>b){return a;}else{return b;}}
int min(int a,int b){if(a<b){return a;}else{return b;}}
int power(int b,int e)
{
    if(e==0)
    return 1;
    if(e%2)
    return ((b*power((b)*(b),(e-1)/2)));
    else
    return power((b)*(b),e/2);
}
int modpower(int b,int e,int q)
{
    int MOD=q;
    if(e==0)
    return 1;
    if(e%2)
    return ((b%MOD)*modpower((b%MOD)*(b%MOD),(e-1)/2,q))%MOD;
    else
    return modpower((b%MOD)*(b%MOD),e/2,q)%MOD;
}
void dpv(vi v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
void dpv(vpii v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i].F<<" "<<v[i].S<<endl;
    }
}
void dpv(set <int> v)
{
    for(auto i:v)
    {
        cout<<i<<" ";
    }
    cout<<endl;
}
//////////////////////**TREE MOVES STARTS**//////////////////////////////
///// **TREE MOVES ENDS**////////////////////////////

////*SOLUTION TO THE QUESTION STARTS HERE*///////
//ool vis[105][105];
bool gr(int a,int b)
{
    return (a>b);
}
void oblivious()
{
    int n,d,m;
    cin>>n>>d>>m;
    vi a,b;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(x>m)
        {
            a.pb(x);
        }
        else
        {
            b.pb(x);
        }
    }
    int ans=0;
    sort(all(a),gr);
    sort(all(b),gr);
    if(sz(a)==0)
    {
        for(int j=0;j<n;j++)
        {
            ans+=b[j];
        }
    }
    else
    {
        for(int i=(sz(a)+d)/(1+d);i<sz(a);i++)
        {
            int f1=(i-1)*(d+1)+1;
            int f2=n-f1;
            if(f1<=n)
            {
                int s1=0;
                for(int j=0;j<i;j++)
                {
                    s1+=a[j];
                }
                for(int j=0;j<f2;j++)
                {
                    s1+=b[j];
                }
                ans=max(ans,s1);
            }
        }
    }
    cout<<ans<<endl;
}
signed main()
{
    IOS;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    int t=1;
    //cin>>t;
    while(t--)
    {
        oblivious();
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<string>
#include<map>
typedef long long ll;
#define init(x,y) memset((x),(y),sizeof((x)));
using namespace std;
const int _N=1e5+10,mod=1e9+7,INF=0x3f3f3f3f;
struct node{int num,lo;}f[_N];
bool cmp(node x,node y){
    return x.num>y.num;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    // freopen("tp.txt","r",stdin);
    ll n,m,k,head,tail,ans=0,tp=0;
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++){
        cin>>f[i].num;
    }
    sort(f+1,f+1+n,cmp);
    head=1,tail=n;
    while(head<=tail){
        if(f[head].num<=k){
            while(head<=tail){
                ans+=f[head].num;
                head++;
            }
            ans+=tp;
            break;
        }
        if(tail-head<=m){
            while(f[tail].num<=k) ans+=f[tail].num,tail--;
            ans+=f[head].num;
            break;
        }
        tp=0;
        for(int i=tail;i>tail-m;i--){
            tp+=f[i].num;
        }
        if(f[head].num>tp){
            ans+=f[head].num;
            head++;
            tail-=m;
        }
        if(f[head].num<tp){
            while(f[tail].num<=k) ans+=f[tail].num,tail--;
            while(head<=tail){
                ans+=f[head].num;
                head++;
                tail-=m;
            }
        }
    }
    cout<<ans<<'\n';
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<string>
#include<map>
typedef long long ll;
#define init(x,y) memset((x),(y),sizeof((x)));
using namespace std;
const int _N=1e3+10,mod=1e9+7,INF=0x3f3f3f3f;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    // freopen("tp.txt","r",stdin);
    ll n,m,k,tp1=0,tp2=0,ans=0,tp=0,f[_N]={0},g[_N]={0},pre[_N]={0},num;
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++){
        cin>>tp;
        if(tp<=k) f[++tp1]=tp;
        else g[++tp2]=tp;
    }
    sort(f+1,f+1+n);reverse(f+1,f+1+n);
    sort(g+1,g+1+n);reverse(g+1,g+1+n);
    for(int i=1;i<=n;i++) pre[i]=pre[i-1]+f[i];
    num=pre[n];
    for(int i=1;i<=tp2;i++){
        ans+=g[i];
        int left=(i-1)*(m+1)+1;
        if(left>n) break;
        left=n-left;
        num=max(num,ans+pre[left]);
    }
    cout<<num<<'\n';
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<string>
#include<map>
typedef long long ll;
#define init(x,y) memset((x),(y),sizeof((x)));
using namespace std;
const int _N=1e3+10,mod=1e9+7,INF=0x3f3f3f3f;
struct node{int num,lo;}f[_N];
bool cmp(node x,node y){
    return x.num>y.num;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    // freopen("tp.txt","r",stdin);
    int n,m,k,head,tail,ans=0,tp=0;
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++){
        cin>>f[i].num;
    }
    sort(f+1,f+1+n,cmp);
    for(int i=1;i<=n;i++){
        f[i].lo=i;
    }
    head=1,tail=n;
    while(head<=tail){
        if(f[head].num<=k){
            while(head<=tail){
                ans+=f[head].num;
                head++;
            }
            ans+=tp;
            break;
        }
        if(tail-head<=m){
            while(f[tail].num<=k) ans+=f[tail].num,tail--;
            ans+=f[head].num;
            break;
        }
        tp=0;
        for(int i=tail;i>tail-m;i--){
            tp+=f[i].num;
        }
        if(f[head].num>tp){
            ans+=f[head].num;
            head++;
            tail-=m;
        }
        if(f[head].num<tp){
            while(f[tail].num<=k) ans+=f[tail].num,tail--;
            while(head<=tail){
                ans+=f[head].num;
                head++;
                tail-=m;
            }
        }
    }
    cout<<ans<<'\n';
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<string>
#include<map>
typedef long long ll;
#define init(x,y) memset((x),(y),sizeof((x)));
using namespace std;
const int _N=1e3+10,mod=1e9+7,INF=0x3f3f3f3f;
struct node{int num,lo;}f[_N];
bool cmp(node x,node y){
    return x.num>y.num;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    // freopen("tp.txt","r",stdin);
    int n,m,k,head,tail,ans=0,tp;
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++){
        cin>>f[i].num;
    }
    sort(f+1,f+1+n,cmp);
    for(int i=1;i<=n;i++){
        f[i].lo=i;
    }
    head=1,tail=n;
    while(head<=tail){
        if(f[head].num<=k){
            while(head<=tail){
                ans+=f[head].num;
                head++;
            }
            ans+=tp;
            break;
        }
        if(tail-head<=m){
            while(f[tail].num<=k) ans+=f[tail].num,tail--;
            ans+=f[head].num;
            break;
        }
        tp=0;
        for(int i=tail;i>tail-m;i--){
            tp+=f[i].num;
        }
        if(f[head].num>tp){
            ans+=f[head].num;
            head++;
            tail-=m;
        }
        if(f[head].num<tp){
            while(f[tail].num<=k) ans+=f[tail].num,tail--;
            while(head<=tail){
                ans+=f[head].num;
                head++;
                tail-=m;
            }
        }
    }
    cout<<ans<<'\n';
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<string>
#include<map>
typedef long long ll;
#define init(x,y) memset((x),(y),sizeof((x)));
using namespace std;
const int _N=1e5+10,mod=1e9+7,INF=0x3f3f3f3f;
struct node{int num,lo;}f[_N];
bool cmp(node x,node y){
    return x.num>y.num;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    // freopen("tp.txt","r",stdin);
    int n,m,k,head,tail,ans=0,tp=0;
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++){
        cin>>f[i].num;
    }
    sort(f+1,f+1+n,cmp);
    for(int i=1;i<=n;i++){
        f[i].lo=i;
    }
    head=1,tail=n;
    while(head<=tail){
        if(f[head].num<=k){
            while(head<=tail){
                ans+=f[head].num;
                head++;
            }
            ans+=tp;
            break;
        }
        if(tail-head<=m){
            while(f[tail].num<=k) ans+=f[tail].num,tail--;
            ans+=f[head].num;
            break;
        }
        tp=0;
        for(int i=tail;i>tail-m;i--){
            tp+=f[i].num;
        }
        if(f[head].num>tp){
            ans+=f[head].num;
            head++;
            tail-=m;
        }
        if(f[head].num<tp){
            while(f[tail].num<=k) ans+=f[tail].num,tail--;
            while(head<=tail){
                ans+=f[head].num;
                head++;
                tail-=m;
            }
        }
    }
    cout<<ans<<'\n';
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<string>
#include<map>
typedef long long ll;
#define init(x,y) memset((x),(y),sizeof((x)));
using namespace std;
const int _N=1e5+10,mod=1e9+7,INF=0x3f3f3f3f;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    // freopen("tp.txt","r",stdin);
    ll n,m,k,head,tail,ans=0,tp=0,f[_N];
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++){
        cin>>f[i];
    }
    sort(f+1,f+1+n);reverse(f+1,f+1+n);
    head=1,tail=n;
    while(head<=tail){
        if(f[head]<=k){
            while(head<=tail){
                ans+=f[head];
                head++;
            }
            ans+=tp;
            break;
        }
        if(tail-head<=m){
            while(f[tail]<=k) ans+=f[tail],tail--;
            ans+=f[head];
            break;
        }
        tp=0;
        for(int i=tail;i>tail-m;i--){
            tp+=f[i];
        }
        if(f[head]>tp){
            ans+=f[head];
            head++;
            tail-=m;
        }
        if(f[head]<=tp){
            while(f[tail]<=k) ans+=f[tail],tail--;
            while(head<=tail){
                ans+=f[head];
                head++;
                tail-=m;
            }
            break;
        }
    }
    cout<<ans<<'\n';
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<string>
#include<map>
typedef long long ll;
#define init(x,y) memset((x),(y),sizeof((x)));
using namespace std;
const int _N=1e5+10,mod=1e9+7,INF=0x3f3f3f3f;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    // freopen("tp.txt","r",stdin);
    ll n,m,k,head,tail,ans=0,tp=0,f[_N];
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++){
        cin>>f[i];
    }
    sort(f+1,f+1+n);reverse(f+1,f+1+n);
    head=1,tail=n;
    while(head<=tail){
        if(f[head]<=k){
            while(head<=tail){
                ans+=f[head];
                head++;
            }
            ans+=tp;
            break;
        }
        if(tail-head<=m){
            while(f[tail]<=k) ans+=f[tail],tail--;
            ans+=max(f[head],tp);
            break;
        }
        tp=0;
        for(int i=tail;i>tail-m;i--){
            tp+=f[i];
        }
        if(f[head]>tp){
            ans+=f[head];
            head++;
            tail-=m;
        }
        if(f[head]<=tp){
            while(f[tail]<=k) ans+=f[tail],tail--;
            while(head<=tail){
                ans+=f[head];
                head++;
                tail-=m;
            }
            break;
        }
    }
    cout<<ans<<'\n';
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<string>
#include<map>
typedef long long ll;
#define init(x,y) memset((x),(y),sizeof((x)));
using namespace std;
const int _N=1e5+10,mod=1e9+7,INF=0x3f3f3f3f;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    // freopen("tp.txt","r",stdin);
    ll n,m,k,tp1=0,tp2=0,ans=0,tp=0,f[_N]={0},g[_N]={0},pre[_N]={0},num;
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++){
        cin>>tp;
        if(tp<=k) f[++tp1]=tp;
        else g[++tp2]=tp;
    }
    sort(f+1,f+1+n);reverse(f+1,f+1+n);
    sort(g+1,g+1+n);reverse(g+1,g+1+n);
    for(int i=1;i<=n;i++) pre[i]=pre[i-1]+f[i];
    num=pre[n];
    for(int i=1;i<=tp2;i++){
        ans+=g[i];
        int left=(i-1)*(m+1)+1;
        if(left>n) break;
        left=n-left;
        num=max(num,ans+pre[left]);
    }
    cout<<num<<'\n';
}


///   BISMILLAHIR RAHMANIR RAHEEM
///   ALLAH IS WATCHING ME
///   ALLAH save us from COVID-19.Amin.

///   Every soul shall taste death.

///   Tag ::

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

/// faster.
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

///  order_of_key return number of elements less than x.
///  find_by_order return index.

using namespace std;
using namespace __gnu_pbds;

#define MOHAMMAD  ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#define all(x)    (x).begin(), (x).end()
#define AE        cout << fixed << setprecision(10);

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; // 8-direction.......
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[]= {1,-1,0,0}; // 4-direction...........
int dy4[]= {0,0,1,-1};

using ll = long long;
const ll MOD = 1e9 + 7;

typedef tree< int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;

//debug
template<typename F,typename S>ostream&operator<<(ostream&os,const pair<F,S>&p){return os<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&v){os<<"{";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<*it;}return os<<"}";}
template<typename T>ostream&operator<<(ostream&os,const set<T>&v){os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<",";os<<*it;}return os<<"]";}
template<typename T>ostream&operator<<(ostream&os,const multiset<T>&v) {os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<*it;}return os<<"]";}
template<typename F,typename S>ostream&operator<<(ostream&os,const map<F,S>&v){os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<it->first<<" = "<<it->second;}return os<<"]";}
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu(){cerr << endl;}
template<typename T>void faltu(T a[],int n){for(int i=0;i<n;++i)cerr<<a[i]<<' ';cerr<<endl;}
template<typename T,typename...hello>void faltu(T arg,const hello&...rest){cerr<<arg<<' ';faltu(rest...);}
//#else
//#define dbg(args...)

/// Modular arithmetic
inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }  /// When MOD is prime.
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

//***********************************************  The END **********************************************************************************************************************************
const ll N = 1e6;
const ll INF = 1e15;

ll a[N+1] , n , d , m , tot = 0;
vector < ll > small , big;

int main()
{

   MOHAMMAD

   ll t = 1;

   /// cin >> t;

   while ( t-- ){

        cin >> n >> d >> m;

        for ( ll i = 1 ; i<=n ; i++ ){
                cin >> a[i];
                if(a[i]>m) tot++;
                else small.push_back ( a[i] );
        }

        sort ( a+1 , a+n+1 , greater<ll>() );

        sort( all(small) );
        reverse ( all(small) );

        for ( ll i = 1 ; i<=n ; ++i ) {
             a[i] = a[i-1] + a[i];
        }

        ll ans = 0;

        for ( ll i = 1 ; i<=tot ; ++i ){
             ll cut = n - ((i-1)*(d+1) + 1);
             ans = max ( ans , a[i] + a[min(n,i+cut)] - a[tot] );
        }

        cout << ans << "\n";

   }
}

/*

  Alhamdulillah
*/


///   BISMILLAHIR RAHMANIR RAHEEM
///   ALLAH IS WATCHING ME
///   ALLAH save us from COVID-19.Amin.

///   Every soul shall taste death.

///   Tag ::

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

/// faster.
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

///  order_of_key return number of elements less than x.
///  find_by_order return index.

using namespace std;
using namespace __gnu_pbds;

#define MOHAMMAD  ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#define all(x)    (x).begin(), (x).end()
#define AE        cout << fixed << setprecision(10);

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; // 8-direction.......
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[]= {1,-1,0,0}; // 4-direction...........
int dy4[]= {0,0,1,-1};

using ll = long long;
const ll MOD = 1e9 + 7;

typedef tree< int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;

//debug
template<typename F,typename S>ostream&operator<<(ostream&os,const pair<F,S>&p){return os<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&v){os<<"{";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<*it;}return os<<"}";}
template<typename T>ostream&operator<<(ostream&os,const set<T>&v){os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<",";os<<*it;}return os<<"]";}
template<typename T>ostream&operator<<(ostream&os,const multiset<T>&v) {os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<*it;}return os<<"]";}
template<typename F,typename S>ostream&operator<<(ostream&os,const map<F,S>&v){os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<it->first<<" = "<<it->second;}return os<<"]";}
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu(){cerr << endl;}
template<typename T>void faltu(T a[],int n){for(int i=0;i<n;++i)cerr<<a[i]<<' ';cerr<<endl;}
template<typename T,typename...hello>void faltu(T arg,const hello&...rest){cerr<<arg<<' ';faltu(rest...);}
//#else
//#define dbg(args...)

/// Modular arithmetic
inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }  /// When MOD is prime.
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

//***********************************************  The END **********************************************************************************************************************************
const ll N = 1e6;
const ll INF = 1e15;

ll a[N+1] , n , d , m , tot = 0;
vector < ll > small , big;

int main()
{

   MOHAMMAD

   ll t = 1;

   /// cin >> t;

   while ( t-- ){

        cin >> n >> d >> m;

        for ( ll i = 1 ; i<=n ; i++ ){
                cin >> a[i];
                if(a[i]>m) tot++;
                else small.push_back ( a[i] );
        }

        sort ( a+1 , a+n+1 , greater<ll>() );

        sort( all(small) );
        reverse ( all(small) );

        for ( ll i = 1 ; i<=n ; ++i ) {
             a[i] = a[i-1] + a[i];
        }

        if ( !tot ) {
                cout << a[n];
                return 0;
        }

        ll ans = 0;

        for ( ll i = 1 ; i<=tot ; ++i ){
             ll cut = n - ((i-1)*(d+1) + 1);
             ans = max ( ans , a[i] + a[min(n,i+cut)] - a[tot] );
        }

        cout << ans << "\n";

   }
}

/*

  Alhamdulillah
*/