//  D.cpp
//  Created by David del Val on 12/08/2020
//
//

#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define fi first
#define se second
//gcd(0, n) = n
inline long long _gcd(long long a, long long b) {
    while (b) b %= a ^= b ^= a ^= b;
    return a;
}
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
inline pii operator+(pii a, pii b) {
    return {a.fi + b.fi, a.se + b.se};
}

inline ostream& operator<<(ostream& o, pii p) {
    o << p.fi << " " << p.se;
    return o;
}

template <typename>
struct is_std_vector : std::false_type {};
template <typename T, typename A>
struct is_std_vector<std::vector<T, A>> : std::true_type {};

template <typename T>
inline ostream& operator<<(ostream& o, vector<T>& p) {
    for (int i = 0; i < p.size(); ++i) {
        o << setw(3) << p[i];
        if (is_std_vector<T>::value) o << "\n";
    }
    return o;
}

#ifdef _LOCAL_
//Local constraints

#else
// Judge constraints
#endif

const int lim = 1e5 + 10;
int n, d, m;
vi great;
vi smal;
vi sol;

ll fill() {
    if (great.size() > 0) sol[n - 1] = great[0];
    int fpos = 0;
    for (int i = 0; i < (int)great.size() - 1; ++i) {
        if ((d + 1) * (i + 1) > n - 1) break;
        //cout << (int)great.size() - 1 - i<<endl;
        sol[(d + 1) * i] = great[(int)great.size() - 1 - i];
        great[(int)great.size() - 1 - i] = -1;
        fpos = (d + 1) * (i + 1);
    }
    int i = 0;
    //cout << smal<<endl;
    //cout << sol<<endl;
    if (smal.size() > 0) {
        for (int p = fpos; p < n - (great.size() > 0); ++p) {
            sol[p] = smal[i];
            smal[i] = -1;
            i++;
        }
        //cout << sol << endl;
        for (int j = 0; j < n; j += d + 1) {
            if (j > n - (d + 1)) break;
            if ((int)smal.size() - i < d + 1) break;
            if (sol[j] <= m || sol[j] == -1) break;
            ll eqsum = 0;
            for (int w = 0; w < d + 1; ++w) eqsum += smal[i + w];
            if (sol[j] < eqsum) {
                for (int w = 0; w < d + 1; ++w) {
                    sol[j + w] = smal[i + w];
                    smal[i + w] = -1;
                }
                i += d + 1;
            }
        }
    }
    ll cnt = 0;
    for (int i = 0; i < n; ++i) {
        if (sol[i] != -1) cnt += sol[i];
    }
    return cnt;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> d >> m;

    great = vi();
    smal = vi();
    great.reserve(n);
    smal.reserve(n);
    sol = vi(n, -1);
    int a;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        if (a > m) {
            great.push_back(a);
        } else {
            smal.push_back(a);
        }
    }
    sort(all(great), greater<int>());
    sort(all(smal), greater<int>());
    //cout << great << endl;
    //cout << smal << endl;
    cout << fill() << "\n";
    /*for (auto a : sol) {
        cout << a << " ";
    }*/

    return 0;
}


//  D.cpp
//  Created by David del Val on 12/08/2020
//
//

#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define fi first
#define se second
//gcd(0, n) = n
inline long long _gcd(long long a, long long b) {
    while (b) b %= a ^= b ^= a ^= b;
    return a;
}
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
inline pii operator+(pii a, pii b) {
    return {a.fi + b.fi, a.se + b.se};
}

inline ostream& operator<<(ostream& o, pii p) {
    o << p.fi << " " << p.se;
    return o;
}

template <typename>
struct is_std_vector : std::false_type {};
template <typename T, typename A>
struct is_std_vector<std::vector<T, A>> : std::true_type {};

template <typename T>
inline ostream& operator<<(ostream& o, vector<T>& p) {
    for (int i = 0; i < p.size(); ++i) {
        o << setw(3) << p[i];
        if (is_std_vector<T>::value) o << "\n";
    }
    return o;
}

#ifdef _LOCAL_
//Local constraints

#else
// Judge constraints
#endif

const int lim = 1e5 + 10;
int n, d, m;
vi great;
vi smal;
vi sol;

ll fill() {
    if (great.size() > 0) sol[n - 1] = great[0];
    int fpos = 0;
    for (int i = 0; i < (int)great.size() - 1; ++i) {
        if ((d + 1) * (i + 1) > n - 1) break;
        //cout << (int)great.size() - 1 - i<<endl;
        sol[(d + 1) * i] = great[(int)great.size() - 1 - i];
        great[(int)great.size() - 1 - i] = -1;
        fpos = (d + 1) * (i + 1);
    }
    int i = 0;
    //cout << smal<<endl;
    //cout << sol<<endl;
    if (smal.size() > 0) {
        for (int p = fpos; p < n - (great.size() > 0); ++p) {
            sol[p] = smal[i];
            smal[i] = -1;
            i++;
        }
        //cout << sol << endl;
        for (int j = 0; j < n; j += d + 1) {
            if (j > n - (d + 1)) break;
            if ((int)smal.size() - i < d + 1) break;
            if (sol[j] <= m) break;
            ll eqsum = 0;
            for (int w = 0; w < d + 1; ++w) eqsum += smal[i + w];
            if (sol[j] < eqsum) {
                for (int w = 0; w < d + 1; ++w) {
                    sol[j + w] = smal[i + w];
                    smal[i + w] = -1;
                }
                i += d + 1;
            }
        }
    }
    ll cnt = 0;
    for (int i = 0; i < n; ++i) {
        if (sol[i] != -1) cnt += sol[i];
    }
    return cnt;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> d >> m;

    great = vi();
    smal = vi();
    great.reserve(n);
    smal.reserve(n);
    sol = vi(n, -1);
    int a;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        if (a > m) {
            great.push_back(a);
        } else {
            smal.push_back(a);
        }
    }
    sort(all(great), greater<int>());
    sort(all(smal), greater<int>());
    //cout << great << endl;
    //cout << smal << endl;
    cout << fill() << "\n";
    /**for (auto a : sol) {
        cout << a << " ";
    }*/

    return 0;
}


//  D.cpp
//  Created by David del Val on 12/08/2020
//
//

#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define fi first
#define se second
//gcd(0, n) = n
inline long long _gcd(long long a, long long b) {
    while (b) b %= a ^= b ^= a ^= b;
    return a;
}
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
inline pii operator+(pii a, pii b) {
    return {a.fi + b.fi, a.se + b.se};
}

inline ostream& operator<<(ostream& o, pii p) {
    o << p.fi << " " << p.se;
    return o;
}

template <typename>
struct is_std_vector : std::false_type {};
template <typename T, typename A>
struct is_std_vector<std::vector<T, A>> : std::true_type {};

template <typename T>
inline ostream& operator<<(ostream& o, vector<T>& p) {
    for (int i = 0; i < p.size(); ++i) {
        o << setw(3) << p[i];
        if (is_std_vector<T>::value) o << "\n";
    }
    return o;
}

#ifdef _LOCAL_
//Local constraints

#else
// Judge constraints
#endif

const int lim = 1e5 + 10;
int n, d, m;
vi great;
vi smal;
vi sol;

ll fill() {
    if (great.size() > 0) sol[n - 1] = great[0];
    int fpos = 0;
    for (int i = 0; i < (int)great.size() - 1; ++i) {
        if ((d + 1) * i > n - (d + 1)) break;
        //cout << (int)great.size() - 1 - i<<endl;
        sol[(d + 1) * i] = great[(int)great.size() - 1 - i];
        great[(int)great.size() - 1 - i] = -1;
        fpos = (d + 1) * (i + 1);
    }
    int i = 0;
    //cout << smal<<endl;
    //cout << sol<<endl;
    if (smal.size() > 0) {
        for (int p = fpos; p < n - (great.size() > 0); ++p) {
            sol[p] = smal[i];
            smal[i] = -1;
            i++;
        }
        //cout << sol << endl;
        vi rem;
        for (int j = 0; j < n; j += d + 1) {
            if (j > n - (d + 1)) break;
            if ((int)smal.size() - i < d + 1) break;
            if (sol[j] <= m) break;
            ll eqsum = 0;
            for (int w = 0; w < d + 1; ++w) eqsum += smal[i + w];
            if (sol[j] < eqsum) {
                rem.push_back(sol[j]);
                for (int w = 0; w < d + 1; ++w) {
                    sol[j + w] = smal[i + w];
                    smal[i + w] = -1;
                }
                i += d + 1;
            }
        }
    }
    ll cnt = 0;
    for (int i = 0; i < n; ++i) {
        if (sol[i] != -1) cnt += sol[i];
    }
    return cnt;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> d >> m;

    great = vi();
    smal = vi();
    great.reserve(n);
    smal.reserve(n);
    sol = vi(n, -1);
    int a;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        if (a > m) {
            great.push_back(a);
        } else {
            smal.push_back(a);
        }
    }
    sort(all(great), greater<int>());
    sort(all(smal), greater<int>());
    //cout << great << endl;
    //cout << smal << endl;
    cout << fill() << "\n";
    /**for (auto a : sol) {
        cout << a << " ";
    }*/

    return 0;
}


//  1394-A.cpp
//  Created by David del Val on 13/08/2020
//
//

#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define fi first
#define se second
//gcd(0, n) = n
inline long long _gcd(long long a, long long b) {
    while (b) b %= a ^= b ^= a ^= b;
    return a;
}
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
inline pii operator+(pii a, pii b) {
    return {a.fi + b.fi, a.se + b.se};
}

inline ostream& operator<<(ostream& o, pii p) {
    o << p.fi << " " << p.se;
    return o;
}

template <typename>
struct is_std_vector : std::false_type {};
template <typename T, typename A>
struct is_std_vector<std::vector<T, A>> : std::true_type {};

template <typename T>
inline ostream& operator<<(ostream& o, vector<T>& p) {
    for (int i = 0; i < p.size(); ++i) {
        o << setw(3) << p[i];
        if (is_std_vector<T>::value) o << "\n";
    }
    return o;
}

#ifdef _LOCAL_
//Local constraints

#else
// Judge constraints
#endif

int n, d, m;
vi small;
vi big;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> d >> m;
    small.reserve(n);
    big.reserve(n);
    int a;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        if (a > m)
            big.push_back(a);
        else
            small.push_back(a);
    }

    if (big.size() == 0) {
        cout << accumulate(all(big), 0LL) << "\n";
    }
    sort(all(big), greater<int>());
    sort(all(small), greater<int>());

    vl bigSum(big.size() + 1);
    vl smallSum(small.size() + 1);
    bigSum[0] = 0;
    smallSum[0] = 0;
    for (int i = 0; i < big.size(); ++i) {
        bigSum[i + 1] = bigSum[i] + big[i];
    }
    for (int i = 0; i < small.size(); ++i) {
        smallSum[i + 1] = smallSum[i] + small[i];
    }
    for (int i = 0; i < big.size(); ++i) smallSum.push_back(smallSum.back());
    ll res = 0;

    for (int chooseBig = (big.size() + 1 + d) / (1 + d); chooseBig < big.size() + 1; ++chooseBig) {
        if (1ll * (chooseBig - 1) * (d + 1) + 1 <= n) {
            ll chooseSmall = n - (1ll * (chooseBig - 1) * (d + 1) + 1);
            //cout << chooseBig << " " << chooseSmall << endl;
            res = max(res, bigSum[chooseBig] + smallSum[chooseSmall]);
        }
    }
    cout << res << "\n";

    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <map>
#define for1(x,y) for(long long x = 1; x<ll(y); x++)
#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
# define PII pair<int,int>
# define FF first
# define SS second
# define PB push_back

#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
using namespace std;
typedef long long ll;
typedef long double ld;

#define maxn 1000015
const double EPS = (1e-7), EPSm= (1e7);
const ll linf = (ll)1e17 + 5;
long double PI = 3.14159265359;
int dir[8][2]={{1,0},{-1,0},{0,1},{0,-1},{-1,-1},{1,1},{-1,1},{1,-1}};

const int MAXN = 1000005;
const int NINF = -1e5;
const int INF = 2000000000;

void solve()
{
	int n,d;
	ll m,cnt=0,less=0;
	cin>>n>>d>>m;
	vector<ll> a(n);
	forn(i,0,n){
		ll x;
		cin>>x;
		if(x<=m)less++;
		a[i]=x;
	}
	sort(a.begin(),a.end(),greater<ll>());
	ll l=0,r=n-1;
	while(1 && l<r){
		if((r-l)<=less){
			for(int i=l;i<=r;i++) cnt+=a[i];
			break;
		}
		if(a[l]>m){
			ll sum=0,j,tod=0;
			for(j=0;j<min(ll(d),less);j++){
				sum+=a[r-j];
				if(a[r-j]<=m) tod++;
			}
			if(sum>=a[l]){
				r-=d;
				cnt+=sum;
				less-=tod;
			}
			else{
				cnt+=a[l];
				l++;
				r-=d;less-=tod;
			}
		}
	}
	cout<<cnt<<endl;
	return;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int test;
	//cin >> test;
	//while(test--)
		solve();
	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <map>
#define for1(x,y) for(long long x = 1; x<ll(y); x++)
#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
# define PII pair<int,int>
# define FF first
# define SS second
# define PB push_back

#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
using namespace std;
typedef long long ll;
typedef long double ld;

const double EPS = (1e-7), EPSm= (1e7);
const ll linf = (ll)1e17 + 5;
long double PI = 3.14159265359;
int dir[8][2]={{1,0},{-1,0},{0,1},{0,-1},{-1,-1},{1,1},{-1,1},{1,-1}};

const int NINF = -1e5;
const int INF = 2000000000;
const int maxn = 1e5;
int n, d, m, k, l;

void make(vector<ll> &pre, ll s){
	sort(pre.begin()+1,pre.end()+1,greater<ll>());
	for(ll i=1;i<=s;i++){
		pre[i]+=pre[i-1];
	}
}

void solve()
{
	cin>>n>>d>>m;
	vector<ll> a(maxn+5,0),b(maxn+5,0);
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		if(x>m) a[++k]=x;
		else b[++l]=x;
	}
	if (k == 0) {
		ll s = 0;
		forn(i, 1, n+1) s += b[i];
		cout<<s<<endl;
		return;
	}
	make(a,k);make(b,l);
	fill(b.begin()+l+1,b.begin()+n+1,b[l]);
	ll res = 0;
	forn(i, 0, k+1) if (1ll * (i - 1) * (d + 1) + 1 <= n) {
		res = max(res, a[i] + b[n - 1ll * (i - 1) * (d + 1) - 1]);
	}
	cout<<res<<endl;
	return;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int test;
	//cin >> test;
	//while(test--)
		solve();
	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <map>
#define for1(x,y) for(long long x = 1; x<ll(y); x++)
#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
# define PII pair<int,int>
# define FF first
# define SS second
# define PB push_back

#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
using namespace std;
typedef long long ll;
typedef long double ld;

#define maxn 1000015
const double EPS = (1e-7), EPSm= (1e7);
const ll linf = (ll)1e17 + 5;
long double PI = 3.14159265359;
int dir[8][2]={{1,0},{-1,0},{0,1},{0,-1},{-1,-1},{1,1},{-1,1},{1,-1}};

const int MAXN = 1000005;
const int NINF = -1e5;
const int INF = 2000000000;

void solve()
{
	int n,d;
	ll m,cnt=0,less=0;
	cin>>n>>d>>m;
	vector<ll> a(n);
	forn(i,0,n){
		ll x;
		cin>>x;
		if(x<=m)less++;
		a[i]=x;
	}
	sort(a.begin(),a.end(),greater<ll>());
	ll l=0,r=n-1;
	while(1 && l<r){
		if((r-l)<=less){
			for(int i=l;i<=r;i++) cnt+=a[i];
			break;
		}
		if(a[l]>m){
			ll sum=0,j,tod=0;
			bool f=0;
			for(j=0;j<min(ll(d),less);j++){
				if(a[r-j]>m) {f=1;break;}
				sum+=a[r-j];
				if(a[r-j]<=m) tod++;
			}
			if(!f && sum>=a[l]){
				r-=d;
				cnt+=sum;
				less-=tod;
			}
			else{
				cnt+=a[l];
				l++;
				r-=d;less-=tod;
			}
		}
	}
	cout<<cnt<<endl;
	return;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int test;
	//cin >> test;
	//while(test--)
		solve();
	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <map>
#define for1(x,y) for(long long x = 1; x<ll(y); x++)
#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
# define PII pair<int,int>
# define FF first
# define SS second
# define PB push_back

#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
using namespace std;
typedef long long ll;
typedef long double ld;

#define maxn 1000015
const double EPS = (1e-7), EPSm= (1e7);
const ll linf = (ll)1e17 + 5;
long double PI = 3.14159265359;
int dir[8][2]={{1,0},{-1,0},{0,1},{0,-1},{-1,-1},{1,1},{-1,1},{1,-1}};

const int MAXN = 1000005;
const int NINF = -1e5;
const int INF = 2000000000;

void solve()
{
	int n,d;
	ll m,cnt=0,less=0;
	cin>>n>>d>>m;
	vector<ll> a,b;
	forn(i,0,n){
		ll x;
		cin>>x;
		if(x<=m) b.PB(x);
		else a.PB(x);
	}
	sort(a.begin(),a.end(),greater<ll>());
	sort(b.begin(),b.end(),greater<ll>());
	ll l1=0,r1=a.size()-1,l2=0,r2=b.size()-1;
	if(a.empty()){
		for(int i=l2;i<=r2;i++){
			cnt+=b[i];
		}
		cout<<cnt<<endl;
		return;
	}
	while(1){
		if(l1==r1){
			for(int i=l2;i<=r2;i++){
				cnt+=b[i];
			}
			cnt+=a[l1];
			break;
		}
		if(r2<=-1) r1-=d;
		else{
			if(r2-l2+1<d){
				r1=r1-(d-(r2-l2+1));
				r2-=d;
			}
			else r2-=d;
		}
		if(r1<l1) break;
		cnt+=a[l1];l1++;
	}
	//cout<<l2<<" "<<r2<<endl;
	cout<<cnt<<endl;
	return;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int test;
	//cin >> test;
	//while(test--)
		solve();
	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <map>
#define for1(x,y) for(long long x = 1; x<ll(y); x++)
#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
# define PII pair<int,int>
# define FF first
# define SS second
# define PB push_back

#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
using namespace std;
typedef long long ll;
typedef long double ld;

#define maxn 1000015
const double EPS = (1e-7), EPSm= (1e7);
const ll linf = (ll)1e17 + 5;
long double PI = 3.14159265359;
int dir[8][2]={{1,0},{-1,0},{0,1},{0,-1},{-1,-1},{1,1},{-1,1},{1,-1}};

const int MAXN = 1000005;
const int NINF = -1e5;
const int INF = 2000000000;

void solve()
{
	int n,d;
	ll m,cnt=0,less=0;
	cin>>n>>d>>m;
	vector<ll> a,b;
	forn(i,0,n){
		ll x;
		cin>>x;
		if(x<=m) b.PB(x);
		else a.PB(x);
	}
	sort(a.begin(),a.end(),greater<ll>());
	sort(b.begin(),b.end(),greater<ll>());
	ll l1=0,r1=a.size()-1,l2=0,r2=b.size()-1;
	if(a.empty()){
		for(int i=l2;i<=r2;i++){
			cnt+=b[i];
		}
		cout<<cnt<<endl;
		return;
	}
	while(1){
		if(l1==r1){
			for(int i=l2;i<=r2;i++){
				cnt+=b[i];
			}
			cnt+=a[l1];
			break;
		}
		if(r2<=-1) r1-=d;
		else{
			if(r2-l2+1<d){
				r1=r1-(d-(r2-l2+1));
				r2-=d;
			}
			else r2-=d;
		}
		cnt+=a[l1];
		if(r1<l1) break;
		l1++;
	}
	//cout<<l2<<" "<<r2<<endl;
	cout<<cnt<<endl;
	return;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int test;
	//cin >> test;
	//while(test--)
		solve();
	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <map>
#define for1(x,y) for(long long x = 1; x<ll(y); x++)
#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
# define PII pair<int,int>
# define FF first
# define SS second
# define PB push_back

#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
using namespace std;
typedef long long ll;
typedef long double ld;

#define maxn 1000015
const double EPS = (1e-7), EPSm= (1e7);
const ll linf = (ll)1e17 + 5;
long double PI = 3.14159265359;
int dir[8][2]={{1,0},{-1,0},{0,1},{0,-1},{-1,-1},{1,1},{-1,1},{1,-1}};

const int MAXN = 1000005;
const int NINF = -1e5;
const int INF = 2000000000;

void solve()
{
	int n,d;
	ll m,cnt=0,less=0;
	cin>>n>>d>>m;
	vector<ll> a(n);
	forn(i,0,n){
		ll x;
		cin>>x;
		if(x<=m)less++;
		a[i]=x;
	}
	sort(a.begin(),a.end(),greater<ll>());
	ll l=0,r=n-1;
	while(1 && l<r){
		if(r-l<=less){
			for(int i=l;i<=r;i++) cnt+=a[i];
			break;
		}
		if(a[l]>m){
			ll sum=0,j,tod=0;
			for(j=0;j<d;j++){
				sum+=a[r-j];
				if(a[r-j]<=m) tod++;
			}
			if(sum>a[l]){
				r-=d;
				cnt+=sum;
				less-=tod;
			}
			else{
				cnt+=a[l];
				l++;
				r-=d;less-=tod;
			}
		}
	}
	cout<<cnt<<endl;
	return;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int test;
	//cin >> test;
	//while(test--)
		solve();
	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <map>
#define for1(x,y) for(long long x = 1; x<ll(y); x++)
#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
# define PII pair<int,int>
# define FF first
# define SS second
# define PB push_back

#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
using namespace std;
typedef long long ll;
typedef long double ld;

const double EPS = (1e-7), EPSm= (1e7);
const ll linf = (ll)1e17 + 5;
long double PI = 3.14159265359;
int dir[8][2]={{1,0},{-1,0},{0,1},{0,-1},{-1,-1},{1,1},{-1,1},{1,-1}};

const int NINF = -1e5;
const int INF = 2000000000;
const int maxn = 1e5;
int n, d, m, k, l;

void make(vector<ll> &pre, ll s){
	sort(pre.begin()+1,pre.end()+1,greater<ll>());
	for(ll i=1;i<=s;i++){
		pre[i]+=pre[i-1];
	}
}

void solve()
{
	cin>>n>>d>>m;
	vector<ll> a(maxn+8,0),b(maxn+8,0);
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		if(x>m) a[++k]=x;
		else b[++l]=x;
	}
	if (k == 0) {
		ll s = 0;
		forn(i, 1, n+1) s += b[i];
		cout<<s<<endl;
		return;
	}
	make(a,k);make(b,l);
	fill(b.begin()+l+1,b.begin()+n+1,b[l]);
	ll res = 0;
	forn(i, 0, k+1) if (1ll * (i - 1) * (d + 1) + 1 <= n) {
		res = max(res, a[i] + b[n - 1ll * (i - 1) * (d + 1) - 1]);
	}
	cout<<res<<endl;
	return;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int test;
	//cin >> test;
	//while(test--)
		solve();
	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <map>
#define for1(x,y) for(long long x = 1; x<ll(y); x++)
#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
# define PII pair<int,int>
# define FF first
# define SS second
# define PB push_back

#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
using namespace std;
typedef long long ll;
typedef long double ld;

#define maxn 1000015
const double EPS = (1e-7), EPSm= (1e7);
const ll linf = (ll)1e17 + 5;
long double PI = 3.14159265359;
int dir[8][2]={{1,0},{-1,0},{0,1},{0,-1},{-1,-1},{1,1},{-1,1},{1,-1}};

const int MAXN = 1000005;
const int NINF = -1e5;
const int INF = 2000000000;

void solve()
{
	int n,d;
	ll m,cnt=0,less=0;
	cin>>n>>d>>m;
	vector<ll> a(n);
	forn(i,0,n){
		ll x;
		cin>>x;
		if(x<=m)less++;
		a[i]=x;
	}
	sort(a.begin(),a.end(),greater<ll>());
	ll l=0,r=n-1;
	while(1 && l<r){
		if(r-l<=less){
			for(int i=l;i<=r;i++) cnt+=a[i];
			break;
		}
		if(a[l]>m){
			ll sum=0,j,tod=0;
			for(j=0;j<min(ll(d),less);j++){
				sum+=a[r-j];
				if(a[r-j]<=m) tod++;
			}
			if(sum>a[l]){
				r-=d;
				cnt+=sum;
				less-=tod;
			}
			else{
				cnt+=a[l];
				l++;
				r-=d;less-=tod;
			}
		}
	}
	cout<<cnt<<endl;
	return;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int test;
	//cin >> test;
	//while(test--)
		solve();
	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <map>
#define for1(x,y) for(long long x = 1; x<ll(y); x++)
#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
# define PII pair<int,int>
# define FF first
# define SS second
# define PB push_back

#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
using namespace std;
typedef long long ll;
typedef long double ld;

const double EPS = (1e-7), EPSm= (1e7);
const ll linf = (ll)1e17 + 5;
long double PI = 3.14159265359;
int dir[8][2]={{1,0},{-1,0},{0,1},{0,-1},{-1,-1},{1,1},{-1,1},{1,-1}};

const int NINF = -1e5;
const int INF = 2000000000;
const int maxn = 1e5;
int n, d, m, k, l;
ll a[maxn+8],b[maxn+8];

void make(ll a[], ll n){
	sort(a + 1, a + n + 1);
	reverse(a + 1, a + n + 1);
	forn(i,1,n+1) a[i]+=a[i-1];
}

void solve()
{
	cin>>n>>d>>m;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		if(x>m) a[++k]=x;
		else b[++l]=x;
	}
	if (k == 0) {
		ll s = 0;
		forn(i, 1, n+1) s += b[i];
		cout<<s<<endl;
		return;
	}
	make(a,k);make(b,l);
	fill(b + l + 1, b + n + 1, b[l]);
	ll res = 0;
	forn(i, (k + d) / (1 + d), k+1) if (1ll * (i - 1) * (d + 1) + 1 <= n) {
		res = max(res, a[i] + b[n - 1ll * (i - 1) * (d + 1) - 1]);
	}
	cout<<res<<endl;
	return;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int test;
	//cin >> test;
	//while(test--)
		solve();
	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <map>
#define for1(x,y) for(long long x = 1; x<ll(y); x++)
#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
# define PII pair<int,int>
# define FF first
# define SS second
# define PB push_back

#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
using namespace std;
typedef long long ll;
typedef long double ld;

const double EPS = (1e-7), EPSm= (1e7);
const ll linf = (ll)1e17 + 5;
long double PI = 3.14159265359;
int dir[8][2]={{1,0},{-1,0},{0,1},{0,-1},{-1,-1},{1,1},{-1,1},{1,-1}};

const int NINF = -1e5;
const int INF = 2000000000;
const int maxn = 1e5;
int n, d, m, k, l;

void make(vector<ll> &pre, ll s){
	sort(pre.begin()+1,pre.end()+1,greater<ll>());
	for(ll i=1;i<=s;i++){
		pre[i]+=pre[i-1];
	}
}

void solve()
{
	cin>>n>>d>>m;
	vector<ll> a(maxn+5,0),b(maxn+5,0);
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		if(x>m) a[++k]=x;
		else b[++l]=x;
	}
	if (k == 0) {
		ll s = 0;
		forn(i, 1, n+1) s += b[i];
		cout<<s<<endl;
		return;
	}
	make(a,k);make(b,l);
	//fill(b.begin()+l+1,b.begin()+n+1,b[l]);
	ll res = 0;
	forn(i, 0, k+1) if (1ll * (i - 1) * (d + 1) + 1 <= n) {
		res = max(res, a[i] + b[n - 1ll * (i - 1) * (d + 1) - 1]);
	}
	cout<<res<<endl;
	return;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int test;
	//cin >> test;
	//while(test--)
		solve();
	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <map>
#define for1(x,y) for(long long x = 1; x<ll(y); x++)
#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
# define PII pair<int,int>
# define FF first
# define SS second
# define PB push_back

#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
using namespace std;
typedef long long ll;
typedef long double ld;

#define maxn 1000015
const double EPS = (1e-7), EPSm= (1e7);
const ll linf = (ll)1e17 + 5;
long double PI = 3.14159265359;
int dir[8][2]={{1,0},{-1,0},{0,1},{0,-1},{-1,-1},{1,1},{-1,1},{1,-1}};

const int MAXN = 1000005;
const int NINF = -1e5;
const int INF = 2000000000;

void solve()
{
	int n,d;
	ll m,cnt=0,less=0;
	cin>>n>>d>>m;
	vector<ll> a(n);
	forn(i,0,n){
		ll x;
		cin>>x;
		if(x<=m)less++;
		a[i]=x;
	}
	sort(a.begin(),a.end(),greater<ll>());
	ll l=0,r=n-1;
	while(1 && l<r){
		if((r-l)==less){
			for(int i=l;i<=r;i++) cnt+=a[i];
			break;
		}
		if(a[l]>m){
			ll sum=0,j,tod=0;
			for(j=0;j<min(ll(d),less);j++){
				sum+=a[r-j];
				if(a[r-j]<=m) tod++;
			}
			if(sum>=a[l]){
				r-=d;
				cnt+=sum;
				less-=tod;
			}
			else{
				cnt+=a[l];
				l++;
				r-=d;less-=tod;
			}
		}
	}
	cout<<cnt<<endl;
	return;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int test;
	//cin >> test;
	//while(test--)
		solve();
	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <map>
#define for1(x,y) for(long long x = 1; x<ll(y); x++)
#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
# define PII pair<int,int>
# define FF first
# define SS second
# define PB push_back

#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
using namespace std;
typedef long long ll;
typedef long double ld;

#define maxn 1000015
const double EPS = (1e-7), EPSm= (1e7);
const ll linf = (ll)1e17 + 5;
long double PI = 3.14159265359;
int dir[8][2]={{1,0},{-1,0},{0,1},{0,-1},{-1,-1},{1,1},{-1,1},{1,-1}};

const int MAXN = 1000005;
const int NINF = -1e5;
const int INF = 2000000000;

void solve()
{
	int n,d;
	ll m,cnt=0,less=0;
	cin>>n>>d>>m;
	vector<ll> a,b;
	forn(i,0,n){
		ll x;
		cin>>x;
		if(x<=m) b.PB(x);
		else a.PB(x);
	}
	sort(a.begin(),a.end(),greater<ll>());
	sort(b.begin(),b.end(),greater<ll>());
	ll l1=0,r1=a.size()-1,l2=0,r2=b.size()-1;
	while(1){
		if(l1==r1){
			for(int i=l2;i<=r2;i++){
				cnt+=b[i];
			}
			cnt+=a[l1];
			break;
		}
		if(r2<=-1) r1-=d;
		else{
			if(r2-l2+1<d){
				r1=r1-(d-(r2-l2+1));
				r2-=d;
			}
			else r2-=d;
		}
		if(r1<l1) break;
		cnt+=a[l1];l1++;
	}
	//cout<<l2<<" "<<r2<<endl;
	cout<<cnt<<endl;
	return;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int test;
	//cin >> test;
	//while(test--)
		solve();
	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <map>
#define for1(x,y) for(long long x = 1; x<ll(y); x++)
#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
# define PII pair<int,int>
# define FF first
# define SS second
# define PB push_back

#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
using namespace std;
typedef long long ll;
typedef long double ld;

const double EPS = (1e-7), EPSm= (1e7);
const ll linf = (ll)1e17 + 5;
long double PI = 3.14159265359;
int dir[8][2]={{1,0},{-1,0},{0,1},{0,-1},{-1,-1},{1,1},{-1,1},{1,-1}};

const int NINF = -1e5;
const int INF = 2000000000;
const int maxn = 1e5;
int n, d, m, k, l;
ll a[maxn+8],b[maxn+8];

void make(ll a[], ll n){
	sort(a + 1, a + n + 1);
	reverse(a + 1, a + n + 1);
	forn(i,1,n+1) a[i]+=a[i-1];
}

void solve()
{
	cin>>n>>d>>m;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		if(x>m) a[++k]=x;
		else b[++l]=x;
	}
	if (k == 0) {
		ll s = 0;
		forn(i, 1, n+1) s += b[i];
		cout<<s<<endl;
		return;
	}
	make(a,k);make(b,l);
	fill(b + l + 1, b + n + 1, b[l]);
	ll res = 0;
	forn(i, 0, k+1) if (1ll * (i - 1) * (d + 1) + 1 <= n) {
		res = max(res, a[i] + b[n - 1ll * (i - 1) * (d + 1) - 1]);
	}
	cout<<res<<endl;
	return;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int test;
	//cin >> test;
	//while(test--)
		solve();
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int OO = 0x3f3f3f3f;
//const long long OO = (long long) 1e18L+7;
//const unsigned long long UOO = (long long) 10e18+7;
#define lp(i,a,n) for(int i = a ; i < n ; ++i)
#define lpr(i,a,n) for(int i = a ; i >= n ; --i)
#define rep(i,vec) for(int i = 0 ; i < vec.size() ; ++i)
#define reprv(i,vec) for(int i = vec.size()-1; i >=0 ; --i)
#define eps (1e-5)
#define pb(i) push_back(i)
#define EPS 1e-9
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define debug(x) cout<<(#x)<<": \""<<x<<"\""<<endl
#define debugVec(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl

typedef vector<int> vi ;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll ;
typedef pair<int,int> pii ;
typedef vector< pair<int,int> >  vpii;
typedef vector<pair<long long,long long>> vpll;
typedef vector<vector<int> > vvi ;
typedef complex<double> point;
typedef pair<ll,ll> pll;

ll  inv(ll a, ll b) {return 1 < a ? b - inv(b % a, a) * b / a : 1;}
ll  Pow(ll  B,ll  P){ll  R=1; while(P>0)  {if(P&1) R=(R*B);P/=2;B=(B*B);}return R;} //compute b^p
ll  GCD(ll  a,ll  b){ while(b){b ^= a ^=b ^= a %=b;}  return a;}
ll  LCM(ll  a,ll  b) { return (a / GCD(a,b)*b); }
ll  BigMod(ll  B,ll  P,ll  M){ ll  R=1; while(P>0)  {if(P&1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return (ll )R;} //compute b^p%m
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//int i=uniform_int_distribution<int>(1,n)(rng);
///-----------------------------------------------------------------------------

ll n,d,m,t;
vll v1 = {0},v2={0};

///-----------------------------------------------------------------------------
int main()
{
    #ifndef ONLINE_JUDGE
//       freopen( "output.txt" , "w" , stdout ) ;
    //   freopen( "input.txt" , "r" , stdin ) ;
    auto stTime = clock();
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
//    cout.tie(0);
///-----------------------------------------------------------------------------------

    cin >> n >> d >> m;

    lp(i,0,n){
        cin >> t;
        if(t <= m) v1.push_back(t);
        else v2.push_back(t);
    }
    sort(v1.begin()+1,v1.end(),greater<ll>());
    sort(v2.begin()+1,v2.end(),greater<ll>());
    lp(i,1,v1.size()) v1[i] += v1[i-1];
    lp(i,1,v2.size()) v2[i] += v2[i-1];

    ll ans = 0;

    lp(i,1,v2.size()){
        int pos = n - (i-1) * (d+1) -1;
        if(pos < 0 ){
            if(0LL-pos + i >= (ll)v2.size() ) break;
            else pos = 0;
        }
        if(pos >= v1.size()){
            pos = n-(i)*(d+1)-1;
            if(pos < v1.size()) pos = v1.size()-1;
            else break;
        }
        ans = max(ans,v1[pos]+v2[i]);
    }
    if(v2.size()==1) ans = v1[v1.size()-1];

    cout << ans;
///------------------------------------------------------------------------------------
    #ifndef ONLINE_JUDGE
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int OO = 0x3f3f3f3f;
//const long long OO = (long long) 1e18L+7;
//const unsigned long long UOO = (long long) 10e18+7;
#define lp(i,a,n) for(int i = a ; i < n ; ++i)
#define lpr(i,a,n) for(int i = a ; i >= n ; --i)
#define rep(i,vec) for(int i = 0 ; i < vec.size() ; ++i)
#define reprv(i,vec) for(int i = vec.size()-1; i >=0 ; --i)
#define eps (1e-5)
#define pb(i) push_back(i)
#define EPS 1e-9
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define debug(x) cout<<(#x)<<": \""<<x<<"\""<<endl
#define debugVec(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl

typedef vector<int> vi ;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll ;
typedef pair<int,int> pii ;
typedef vector< pair<int,int> >  vpii;
typedef vector<pair<long long,long long>> vpll;
typedef vector<vector<int> > vvi ;
typedef complex<double> point;
typedef pair<ll,ll> pll;

ll  inv(ll a, ll b) {return 1 < a ? b - inv(b % a, a) * b / a : 1;}
ll  Pow(ll  B,ll  P){ll  R=1; while(P>0)  {if(P&1) R=(R*B);P/=2;B=(B*B);}return R;} //compute b^p
ll  GCD(ll  a,ll  b){ while(b){b ^= a ^=b ^= a %=b;}  return a;}
ll  LCM(ll  a,ll  b) { return (a / GCD(a,b)*b); }
ll  BigMod(ll  B,ll  P,ll  M){ ll  R=1; while(P>0)  {if(P&1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return (ll )R;} //compute b^p%m
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//int i=uniform_int_distribution<int>(1,n)(rng);
///-----------------------------------------------------------------------------

ll n,d,m,t;
vll v1,v2;

///-----------------------------------------------------------------------------
int main()
{
    #ifndef ONLINE_JUDGE
//       freopen( "output.txt" , "w" , stdout ) ;
    //   freopen( "input.txt" , "r" , stdin ) ;
    auto stTime = clock();
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
//    cout.tie(0);
///-----------------------------------------------------------------------------------

    cin >> n >> d >> m;
    lp(i,0,n){
        cin >> t;
        if(t <= m) v1.push_back(t);
        else v2.push_back(t);
    }
    sort(all(v1),greater<ll>());
    sort(all(v2),greater<ll>());
    lp(i,1,v1.size()) v1[i] += v1[i-1];
    lp(i,1,v2.size()) v2[i] += v2[i-1];
    ll ans = 0;
    lp(i,0,v2.size()){
        int pos = min(n - (i)*(d+1) - 2,(ll)v1.size()-1);
//        cout << v2[i] << " " << (i)*(d+1)+1 << "\n";
        if(pos < 0 || pos >= v1.size()) ans = max(ans,v2[i]);
        ans = max(ans,v2[i] + v1[pos]);
    }
    if(v2.size()==0) ans = v1[v1.size()-1];

    cout << ans;
///------------------------------------------------------------------------------------
    #ifndef ONLINE_JUDGE
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int OO = 0x3f3f3f3f;
//const long long OO = (long long) 1e18L+7;
//const unsigned long long UOO = (long long) 10e18+7;
#define lp(i,a,n) for(int i = a ; i < n ; ++i)
#define lpr(i,a,n) for(int i = a ; i >= n ; --i)
#define rep(i,vec) for(int i = 0 ; i < vec.size() ; ++i)
#define reprv(i,vec) for(int i = vec.size()-1; i >=0 ; --i)
#define eps (1e-5)
#define pb(i) push_back(i)
#define EPS 1e-9
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define debug(x) cout<<(#x)<<": \""<<x<<"\""<<endl
#define debugVec(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl

typedef vector<int> vi ;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll ;
typedef pair<int,int> pii ;
typedef vector< pair<int,int> >  vpii;
typedef vector<pair<long long,long long>> vpll;
typedef vector<vector<int> > vvi ;
typedef complex<double> point;
typedef pair<ll,ll> pll;

ll  inv(ll a, ll b) {return 1 < a ? b - inv(b % a, a) * b / a : 1;}
ll  Pow(ll  B,ll  P){ll  R=1; while(P>0)  {if(P&1) R=(R*B);P/=2;B=(B*B);}return R;} //compute b^p
ll  GCD(ll  a,ll  b){ while(b){b ^= a ^=b ^= a %=b;}  return a;}
ll  LCM(ll  a,ll  b) { return (a / GCD(a,b)*b); }
ll  BigMod(ll  B,ll  P,ll  M){ ll  R=1; while(P>0)  {if(P&1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return (ll )R;} //compute b^p%m
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//int i=uniform_int_distribution<int>(1,n)(rng);
///-----------------------------------------------------------------------------

ll n,d,m,t;
vll v1 = {0},v2={0};

///-----------------------------------------------------------------------------
int main()
{
    #ifndef ONLINE_JUDGE
//       freopen( "output.txt" , "w" , stdout ) ;
    //   freopen( "input.txt" , "r" , stdin ) ;
    auto stTime = clock();
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
//    cout.tie(0);
///-----------------------------------------------------------------------------------

    cin >> n >> d >> m;

    lp(i,0,n){
        cin >> t;
        if(t <= m) v1.push_back(t);
        else v2.push_back(t);
    }
    sort(v1.begin()+1,v1.end(),greater<ll>());
    sort(v2.begin()+1,v2.end(),greater<ll>());
    lp(i,1,v1.size()) v1[i] += v1[i-1];
    lp(i,1,v2.size()) v2[i] += v2[i-1];

    ll ans = 0;
    lp(i,1,v2.size()){
        int mntaken = 1+(i-1)*(d+1);
        if(n < mntaken) continue;
        int pos = min(n-mntaken,1LL*sz(v1)-1);
        ans = max(ans,v1[pos]+v2[i]);
    }
    if(v2.size()==1) ans = v1[sz(v1)-1];

    cout << ans;
///------------------------------------------------------------------------------------
    #ifndef ONLINE_JUDGE
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int OO = 0x3f3f3f3f;
//const long long OO = (long long) 1e18L+7;
//const unsigned long long UOO = (long long) 10e18+7;
#define lp(i,a,n) for(int i = a ; i < n ; ++i)
#define lpr(i,a,n) for(int i = a ; i >= n ; --i)
#define rep(i,vec) for(int i = 0 ; i < vec.size() ; ++i)
#define reprv(i,vec) for(int i = vec.size()-1; i >=0 ; --i)
#define eps (1e-5)
#define pb(i) push_back(i)
#define EPS 1e-9
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define debug(x) cout<<(#x)<<": \""<<x<<"\""<<endl
#define debugVec(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl

typedef vector<int> vi ;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll ;
typedef pair<int,int> pii ;
typedef vector< pair<int,int> >  vpii;
typedef vector<pair<long long,long long>> vpll;
typedef vector<vector<int> > vvi ;
typedef complex<double> point;
typedef pair<ll,ll> pll;

ll  inv(ll a, ll b) {return 1 < a ? b - inv(b % a, a) * b / a : 1;}
ll  Pow(ll  B,ll  P){ll  R=1; while(P>0)  {if(P&1) R=(R*B);P/=2;B=(B*B);}return R;} //compute b^p
ll  GCD(ll  a,ll  b){ while(b){b ^= a ^=b ^= a %=b;}  return a;}
ll  LCM(ll  a,ll  b) { return (a / GCD(a,b)*b); }
ll  BigMod(ll  B,ll  P,ll  M){ ll  R=1; while(P>0)  {if(P&1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return (ll )R;} //compute b^p%m
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//int i=uniform_int_distribution<int>(1,n)(rng);
///-----------------------------------------------------------------------------

ll n,d,m,t;
vll v1,v2;

///-----------------------------------------------------------------------------
int main()
{
    #ifndef ONLINE_JUDGE
//       freopen( "output.txt" , "w" , stdout ) ;
    //   freopen( "input.txt" , "r" , stdin ) ;
    auto stTime = clock();
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
//    cout.tie(0);
///-----------------------------------------------------------------------------------

    cin >> n >> d >> m;
    lp(i,0,n){
        cin >> t;
        if(t <= m) v1.push_back(t);
        else v2.push_back(t);
    }
    sort(all(v1),greater<ll>());
    sort(all(v2),greater<ll>());
    lp(i,1,v1.size()) v1[i] += v1[i-1];
    lp(i,1,v2.size()) v2[i] += v2[i-1];
    ll ans = 0;
    lp(i,0,v2.size()){
        int pos = min(n - (i)*(d+1) - 2,(ll)v1.size()-1);
//        cout << v2[i] << " " << (i)*(d+1)+1 << "\n";
        if(pos < 0 || pos >= v1.size()) ans = max(ans,v2[i]);
        ans = max(ans,v2[i] + v1[pos]);
    }

    cout << ans;
///------------------------------------------------------------------------------------
    #ifndef ONLINE_JUDGE
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int OO = 0x3f3f3f3f;
//const long long OO = (long long) 1e18L+7;
//const unsigned long long UOO = (long long) 10e18+7;
#define lp(i,a,n) for(int i = a ; i < n ; ++i)
#define lpr(i,a,n) for(int i = a ; i >= n ; --i)
#define rep(i,vec) for(int i = 0 ; i < vec.size() ; ++i)
#define reprv(i,vec) for(int i = vec.size()-1; i >=0 ; --i)
#define eps (1e-5)
#define pb(i) push_back(i)
#define EPS 1e-9
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define debug(x) cout<<(#x)<<": \""<<x<<"\""<<endl
#define debugVec(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl

typedef vector<int> vi ;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll ;
typedef pair<int,int> pii ;
typedef vector< pair<int,int> >  vpii;
typedef vector<pair<long long,long long>> vpll;
typedef vector<vector<int> > vvi ;
typedef complex<double> point;
typedef pair<ll,ll> pll;

ll  inv(ll a, ll b) {return 1 < a ? b - inv(b % a, a) * b / a : 1;}
ll  Pow(ll  B,ll  P){ll  R=1; while(P>0)  {if(P&1) R=(R*B);P/=2;B=(B*B);}return R;} //compute b^p
ll  GCD(ll  a,ll  b){ while(b){b ^= a ^=b ^= a %=b;}  return a;}
ll  LCM(ll  a,ll  b) { return (a / GCD(a,b)*b); }
ll  BigMod(ll  B,ll  P,ll  M){ ll  R=1; while(P>0)  {if(P&1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return (ll )R;} //compute b^p%m
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//int i=uniform_int_distribution<int>(1,n)(rng);
///-----------------------------------------------------------------------------

ll n,d,m,t;
vll v1 = {0},v2={0};

///-----------------------------------------------------------------------------
int main()
{
    #ifndef ONLINE_JUDGE
//       freopen( "output.txt" , "w" , stdout ) ;
    //   freopen( "input.txt" , "r" , stdin ) ;
    auto stTime = clock();
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
//    cout.tie(0);
///-----------------------------------------------------------------------------------

    cin >> n >> d >> m;

    lp(i,0,n){
        cin >> t;
        if(t <= m) v1.push_back(t);
        else v2.push_back(t);
    }
    sort(v1.begin()+1,v1.end(),greater<ll>());
    sort(v2.begin()+1,v2.end(),greater<ll>());
    lp(i,1,v1.size()) v1[i] += v1[i-1];
    lp(i,1,v2.size()) v2[i] += v2[i-1];

    ll ans = 0;

    lp(i,1,v2.size()){
        int pos = n - (i-1) * (d+1) -1;
        if(pos < 0 ){
            if(-pos + i >= v2.size() ) continue;
            else pos = 0;
        }
        if(pos >= v1.size()){
            pos = n-(i)*(d+1)-1;
            if(pos < v1.size()) pos = v1.size()-1;
            else continue;
        }
        ans = max(ans,v1[pos]+v2[i]);
    }
    if(v2.size()==1) ans = v1[v1.size()-1];

    cout << ans;
///------------------------------------------------------------------------------------
    #ifndef ONLINE_JUDGE
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int OO = 0x3f3f3f3f;
//const long long OO = (long long) 1e18L+7;
//const unsigned long long UOO = (long long) 10e18+7;
#define lp(i,a,n) for(int i = a ; i < n ; ++i)
#define lpr(i,a,n) for(int i = a ; i >= n ; --i)
#define rep(i,vec) for(int i = 0 ; i < vec.size() ; ++i)
#define reprv(i,vec) for(int i = vec.size()-1; i >=0 ; --i)
#define eps (1e-5)
#define pb(i) push_back(i)
#define EPS 1e-9
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define debug(x) cout<<(#x)<<": \""<<x<<"\""<<endl
#define debugVec(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl

typedef vector<int> vi ;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll ;
typedef pair<int,int> pii ;
typedef vector< pair<int,int> >  vpii;
typedef vector<pair<long long,long long>> vpll;
typedef vector<vector<int> > vvi ;
typedef complex<double> point;
typedef pair<ll,ll> pll;

ll  inv(ll a, ll b) {return 1 < a ? b - inv(b % a, a) * b / a : 1;}
ll  Pow(ll  B,ll  P){ll  R=1; while(P>0)  {if(P&1) R=(R*B);P/=2;B=(B*B);}return R;} //compute b^p
ll  GCD(ll  a,ll  b){ while(b){b ^= a ^=b ^= a %=b;}  return a;}
ll  LCM(ll  a,ll  b) { return (a / GCD(a,b)*b); }
ll  BigMod(ll  B,ll  P,ll  M){ ll  R=1; while(P>0)  {if(P&1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return (ll )R;} //compute b^p%m
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//int i=uniform_int_distribution<int>(1,n)(rng);
///-----------------------------------------------------------------------------

ll n,d,m,t;
vll v1 = {0},v2={0};

///-----------------------------------------------------------------------------
int main()
{
    #ifndef ONLINE_JUDGE
//       freopen( "output.txt" , "w" , stdout ) ;
    //   freopen( "input.txt" , "r" , stdin ) ;
    auto stTime = clock();
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
//    cout.tie(0);
///-----------------------------------------------------------------------------------

    cin >> n >> d >> m;

    lp(i,0,n){
        cin >> t;
        if(t <= m) v1.push_back(t);
        else v2.push_back(t);
    }
    sort(v1.begin()+1,v1.end(),greater<ll>());
    sort(v2.begin()+1,v2.end(),greater<ll>());
    lp(i,1,v1.size()) v1[i] += v1[i-1];
    lp(i,1,v2.size()) v2[i] += v2[i-1];

    ll ans = 0;

    lp(i,1,v2.size()){
        int pos = n - (i-1) * (d+1) -1;
        if(pos < 0 ){
            if(0LL-pos + i >= (ll)v2.size() ) break;
            else pos = 0;
        }
        if(pos >= v1.size()){
            pos = n-(i)*(d+1)-1;
            if(pos < v1.size()) pos = v1.size()-1;
            else continue;
        }
        ans = max(ans,v1[pos]+v2[i]);
    }
    if(v2.size()==1) ans = v1[v1.size()-1];

    cout << ans;
///------------------------------------------------------------------------------------
    #ifndef ONLINE_JUDGE
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int OO = 0x3f3f3f3f;
//const long long OO = (long long) 1e18L+7;
//const unsigned long long UOO = (long long) 10e18+7;
#define lp(i,a,n) for(int i = a ; i < n ; ++i)
#define lpr(i,a,n) for(int i = a ; i >= n ; --i)
#define rep(i,vec) for(int i = 0 ; i < vec.size() ; ++i)
#define reprv(i,vec) for(int i = vec.size()-1; i >=0 ; --i)
#define eps (1e-5)
#define pb(i) push_back(i)
#define EPS 1e-9
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define debug(x) cout<<(#x)<<": \""<<x<<"\""<<endl
#define debugVec(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl

typedef vector<int> vi ;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll ;
typedef pair<int,int> pii ;
typedef vector< pair<int,int> >  vpii;
typedef vector<pair<long long,long long>> vpll;
typedef vector<vector<int> > vvi ;
typedef complex<double> point;
typedef pair<ll,ll> pll;

ll  inv(ll a, ll b) {return 1 < a ? b - inv(b % a, a) * b / a : 1;}
ll  Pow(ll  B,ll  P){ll  R=1; while(P>0)  {if(P&1) R=(R*B);P/=2;B=(B*B);}return R;} //compute b^p
ll  GCD(ll  a,ll  b){ while(b){b ^= a ^=b ^= a %=b;}  return a;}
ll  LCM(ll  a,ll  b) { return (a / GCD(a,b)*b); }
ll  BigMod(ll  B,ll  P,ll  M){ ll  R=1; while(P>0)  {if(P&1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return (ll )R;} //compute b^p%m
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//int i=uniform_int_distribution<int>(1,n)(rng);
///-----------------------------------------------------------------------------

ll n,d,m,t;
deque<ll> q1,q2,q3;
vll v1,v2;

///-----------------------------------------------------------------------------
int main()
{
    #ifndef ONLINE_JUDGE
//       freopen( "output.txt" , "w" , stdout ) ;
    //   freopen( "input.txt" , "r" , stdin ) ;
    auto stTime = clock();
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
//    cout.tie(0);
///-----------------------------------------------------------------------------------

    cin >> n >> d >> m;
    lp(i,0,n){
        cin >> t;
        if(t <= m) v1.push_back(t);
        else v2.push_back(t);
    }
    sort(all(v1));
    sort(all(v2));
    for(ll x : v1) q1.push_back(x);
    for(ll x : v2) q2.push_back(x);
    ll ans = 0;
    if(q2.size()){
        ans += q2.back();
        q2.pop_back();
    }
    int need = 0;
    while(q2.size()){
        ans += q2.back();
        q2.pop_back();
        need = d;
        while(q2.size()&&need){
            --need;
            q3.push_back(q2.front());
            q2.pop_front();
        }
    }
    while(need&&q1.size()) {
        q1.pop_front();
        --need;
    }

    need = q1.size();
    while(need--){
        ans += q1.front();
        q1.push_back(q1.front());
        q1.pop_front();
    }

    while(q1.size() && q3.size()){
        ll choice = q3.back();
        q3.pop_back();
        need = d+1;
        while(need&&q1.size()){
            choice -= q1.front();
            q1.pop_front();
            --need;
        }
        if(choice > 0) ans += choice;
        else break;
    }

    cout << ans;

///------------------------------------------------------------------------------------
    #ifndef ONLINE_JUDGE
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int OO = 0x3f3f3f3f;
//const long long OO = (long long) 1e18L+7;
//const unsigned long long UOO = (long long) 10e18+7;
#define lp(i,a,n) for(int i = a ; i < n ; ++i)
#define lpr(i,a,n) for(int i = a ; i >= n ; --i)
#define rep(i,vec) for(int i = 0 ; i < vec.size() ; ++i)
#define reprv(i,vec) for(int i = vec.size()-1; i >=0 ; --i)
#define eps (1e-5)
#define pb(i) push_back(i)
#define EPS 1e-9
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define debug(x) cout<<(#x)<<": \""<<x<<"\""<<endl
#define debugVec(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl

typedef vector<int> vi ;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll ;
typedef pair<int,int> pii ;
typedef vector< pair<int,int> >  vpii;
typedef vector<pair<long long,long long>> vpll;
typedef vector<vector<int> > vvi ;
typedef complex<double> point;
typedef pair<ll,ll> pll;

ll  inv(ll a, ll b) {return 1 < a ? b - inv(b % a, a) * b / a : 1;}
ll  Pow(ll  B,ll  P){ll  R=1; while(P>0)  {if(P&1) R=(R*B);P/=2;B=(B*B);}return R;} //compute b^p
ll  GCD(ll  a,ll  b){ while(b){b ^= a ^=b ^= a %=b;}  return a;}
ll  LCM(ll  a,ll  b) { return (a / GCD(a,b)*b); }
ll  BigMod(ll  B,ll  P,ll  M){ ll  R=1; while(P>0)  {if(P&1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return (ll )R;} //compute b^p%m
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//int i=uniform_int_distribution<int>(1,n)(rng);
///-----------------------------------------------------------------------------

ll n,d,m,t;
vll v1 = {0},v2={0};

///-----------------------------------------------------------------------------
int main()
{
    #ifndef ONLINE_JUDGE
//       freopen( "output.txt" , "w" , stdout ) ;
    //   freopen( "input.txt" , "r" , stdin ) ;
    auto stTime = clock();
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
//    cout.tie(0);
///-----------------------------------------------------------------------------------

    cin >> n >> d >> m;

    lp(i,0,n){
        cin >> t;
        if(t <= m) v1.push_back(t);
        else v2.push_back(t);
    }
    sort(v1.begin()+1,v1.end(),greater<ll>());
    sort(v2.begin()+1,v2.end(),greater<ll>());
    lp(i,1,v1.size()) v1[i] += v1[i-1];
    lp(i,1,v2.size()) v2[i] += v2[i-1];

    ll ans = 0;
    lp(i,1,v2.size()){
        int mntaken = 1+(i-1)*(d+1);
        if(n < mntaken) break;
        int pos = min(n-mntaken,1LL*sz(v1)-1);
        ans = max(ans,v1[pos]+v2[i]);
    }
    if(v2.size()==1) ans = v1[sz(v1)-1];

    cout << ans;
///------------------------------------------------------------------------------------
    #ifndef ONLINE_JUDGE
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int OO = 0x3f3f3f3f;
//const long long OO = (long long) 1e18L+7;
//const unsigned long long UOO = (long long) 10e18+7;
#define lp(i,a,n) for(int i = a ; i < n ; ++i)
#define lpr(i,a,n) for(int i = a ; i >= n ; --i)
#define rep(i,vec) for(int i = 0 ; i < vec.size() ; ++i)
#define reprv(i,vec) for(int i = vec.size()-1; i >=0 ; --i)
#define eps (1e-5)
#define pb(i) push_back(i)
#define EPS 1e-9
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define debug(x) cout<<(#x)<<": \""<<x<<"\""<<endl
#define debugVec(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl

typedef vector<int> vi ;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll ;
typedef pair<int,int> pii ;
typedef vector< pair<int,int> >  vpii;
typedef vector<pair<long long,long long>> vpll;
typedef vector<vector<int> > vvi ;
typedef complex<double> point;
typedef pair<ll,ll> pll;

ll  inv(ll a, ll b) {return 1 < a ? b - inv(b % a, a) * b / a : 1;}
ll  Pow(ll  B,ll  P){ll  R=1; while(P>0)  {if(P&1) R=(R*B);P/=2;B=(B*B);}return R;} //compute b^p
ll  GCD(ll  a,ll  b){ while(b){b ^= a ^=b ^= a %=b;}  return a;}
ll  LCM(ll  a,ll  b) { return (a / GCD(a,b)*b); }
ll  BigMod(ll  B,ll  P,ll  M){ ll  R=1; while(P>0)  {if(P&1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return (ll )R;} //compute b^p%m
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//int i=uniform_int_distribution<int>(1,n)(rng);
///-----------------------------------------------------------------------------

ll n,d,m,t;
vll v1,v2;

///-----------------------------------------------------------------------------
int main()
{
    #ifndef ONLINE_JUDGE
//       freopen( "output.txt" , "w" , stdout ) ;
    //   freopen( "input.txt" , "r" , stdin ) ;
    auto stTime = clock();
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
//    cout.tie(0);
///-----------------------------------------------------------------------------------

    cin >> n >> d >> m;
    lp(i,0,n){
        cin >> t;
        if(t <= m) v1.push_back(t);
        else v2.push_back(t);
    }
    sort(all(v1),greater<ll>());
    sort(all(v2),greater<ll>());
    lp(i,1,v1.size()) v1[i] += v1[i-1];
    lp(i,1,v2.size()) v2[i] += v2[i-1];
    ll ans = 0;
    lp(i,0,v2.size()){
        int pos = min(n - (i)*(d+1) - 2,(ll)v1.size()-1);
//        cout << v2[i] << " " << (i)*(d+1)+1 << "\n";
        if(pos < 0 || pos >= v1.size()) ans = max(ans,v2[i]);
        else ans = max(ans,v2[i] + v1[pos]);
    }
    if(v2.size()==0) ans = v1[v1.size()-1];

    cout << ans;
///------------------------------------------------------------------------------------
    #ifndef ONLINE_JUDGE
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int OO = 0x3f3f3f3f;
//const long long OO = (long long) 1e18L+7;
//const unsigned long long UOO = (long long) 10e18+7;
#define lp(i,a,n) for(int i = a ; i < n ; ++i)
#define lpr(i,a,n) for(int i = a ; i >= n ; --i)
#define rep(i,vec) for(int i = 0 ; i < vec.size() ; ++i)
#define reprv(i,vec) for(int i = vec.size()-1; i >=0 ; --i)
#define eps (1e-5)
#define pb(i) push_back(i)
#define EPS 1e-9
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define debug(x) cout<<(#x)<<": \""<<x<<"\""<<endl
#define debugVec(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl

typedef vector<int> vi ;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll ;
typedef pair<int,int> pii ;
typedef vector< pair<int,int> >  vpii;
typedef vector<pair<long long,long long>> vpll;
typedef vector<vector<int> > vvi ;
typedef complex<double> point;
typedef pair<ll,ll> pll;

ll  inv(ll a, ll b) {return 1 < a ? b - inv(b % a, a) * b / a : 1;}
ll  Pow(ll  B,ll  P){ll  R=1; while(P>0)  {if(P&1) R=(R*B);P/=2;B=(B*B);}return R;} //compute b^p
ll  GCD(ll  a,ll  b){ while(b){b ^= a ^=b ^= a %=b;}  return a;}
ll  LCM(ll  a,ll  b) { return (a / GCD(a,b)*b); }
ll  BigMod(ll  B,ll  P,ll  M){ ll  R=1; while(P>0)  {if(P&1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return (ll )R;} //compute b^p%m
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//int i=uniform_int_distribution<int>(1,n)(rng);
///-----------------------------------------------------------------------------

ll n,d,m,t;
vll v1 = {0},v2={0};

///-----------------------------------------------------------------------------
int main()
{
    #ifndef ONLINE_JUDGE
//       freopen( "output.txt" , "w" , stdout ) ;
    //   freopen( "input.txt" , "r" , stdin ) ;
    auto stTime = clock();
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
//    cout.tie(0);
///-----------------------------------------------------------------------------------

    cin >> n >> d >> m;

    lp(i,0,n){
        cin >> t;
        if(t <= m) v1.push_back(t);
        else v2.push_back(t);
    }
    sort(v1.begin()+1,v1.end(),greater<ll>());
    sort(v2.begin()+1,v2.end(),greater<ll>());
    lp(i,1,v1.size()) v1[i] += v1[i-1];
    lp(i,1,v2.size()) v2[i] += v2[i-1];

    ll ans = 0;

    lp(i,1,v2.size()){
        int pos = n - (i-1) * (d+1) -1;
        if(pos < 0 ){
            if(0LL-pos + i >= (ll)v2.size() ) continue;
            else pos = 0;
        }
        if(pos >= v1.size()){
            pos = n-(i)*(d+1)-1;
            if(pos < v1.size()) pos = v1.size()-1;
            else continue;
        }
        ans = max(ans,v1[pos]+v2[i]);
    }
    if(v2.size()==1) ans = v1[v1.size()-1];

    cout << ans;
///------------------------------------------------------------------------------------
    #ifndef ONLINE_JUDGE
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int OO = 0x3f3f3f3f;
//const long long OO = (long long) 1e18L+7;
//const unsigned long long UOO = (long long) 10e18+7;
#define lp(i,a,n) for(int i = a ; i < n ; ++i)
#define lpr(i,a,n) for(int i = a ; i >= n ; --i)
#define rep(i,vec) for(int i = 0 ; i < vec.size() ; ++i)
#define reprv(i,vec) for(int i = vec.size()-1; i >=0 ; --i)
#define eps (1e-5)
#define pb(i) push_back(i)
#define EPS 1e-9
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define debug(x) cout<<(#x)<<": \""<<x<<"\""<<endl
#define debugVec(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl

typedef vector<int> vi ;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll ;
typedef pair<int,int> pii ;
typedef vector< pair<int,int> >  vpii;
typedef vector<pair<long long,long long>> vpll;
typedef vector<vector<int> > vvi ;
typedef complex<double> point;
typedef pair<ll,ll> pll;

ll  inv(ll a, ll b) {return 1 < a ? b - inv(b % a, a) * b / a : 1;}
ll  Pow(ll  B,ll  P){ll  R=1; while(P>0)  {if(P&1) R=(R*B);P/=2;B=(B*B);}return R;} //compute b^p
ll  GCD(ll  a,ll  b){ while(b){b ^= a ^=b ^= a %=b;}  return a;}
ll  LCM(ll  a,ll  b) { return (a / GCD(a,b)*b); }
ll  BigMod(ll  B,ll  P,ll  M){ ll  R=1; while(P>0)  {if(P&1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return (ll )R;} //compute b^p%m
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//int i=uniform_int_distribution<int>(1,n)(rng);
///-----------------------------------------------------------------------------

ll n,d,m,t;
vll v1 = {0},v2={0};

///-----------------------------------------------------------------------------
int main()
{
    #ifndef ONLINE_JUDGE
//       freopen( "output.txt" , "w" , stdout ) ;
    //   freopen( "input.txt" , "r" , stdin ) ;
    auto stTime = clock();
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
//    cout.tie(0);
///-----------------------------------------------------------------------------------

    cin >> n >> d >> m;

    lp(i,0,n){
        cin >> t;
        if(t <= m) v1.push_back(t);
        else v2.push_back(t);
    }
    sort(v1.begin()+1,v1.end(),greater<ll>());
    sort(v2.begin()+1,v2.end(),greater<ll>());
    lp(i,1,v1.size()) v1[i] += v1[i-1];
    lp(i,1,v2.size()) v2[i] += v2[i-1];

    ll ans = 0;

    lp(i,1,v2.size()){
        int pos = n - (i-1) * (d+1) -1;
        if(pos < 0 ){
            if(0LL-pos + i >= (ll)v2.size() ) continue;
            else pos = 0;
        }
        if(pos >= v1.size()){
            pos = n-(i)*(d+1)-1;
            if(pos < v1.size()) pos = v1.size()-1;
            else break;
        }
        ans = max(ans,v1[pos]+v2[i]);
    }
    if(v2.size()==1) ans = v1[v1.size()-1];

    cout << ans;
///------------------------------------------------------------------------------------
    #ifndef ONLINE_JUDGE
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int OO = 0x3f3f3f3f;
//const long long OO = (long long) 1e18L+7;
//const unsigned long long UOO = (long long) 10e18+7;
#define lp(i,a,n) for(int i = a ; i < n ; ++i)
#define lpr(i,a,n) for(int i = a ; i >= n ; --i)
#define rep(i,vec) for(int i = 0 ; i < vec.size() ; ++i)
#define reprv(i,vec) for(int i = vec.size()-1; i >=0 ; --i)
#define eps (1e-5)
#define pb(i) push_back(i)
#define EPS 1e-9
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define debug(x) cout<<(#x)<<": \""<<x<<"\""<<endl
#define debugVec(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl

typedef vector<int> vi ;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll ;
typedef pair<int,int> pii ;
typedef vector< pair<int,int> >  vpii;
typedef vector<pair<long long,long long>> vpll;
typedef vector<vector<int> > vvi ;
typedef complex<double> point;
typedef pair<ll,ll> pll;

ll  inv(ll a, ll b) {return 1 < a ? b - inv(b % a, a) * b / a : 1;}
ll  Pow(ll  B,ll  P){ll  R=1; while(P>0)  {if(P&1) R=(R*B);P/=2;B=(B*B);}return R;} //compute b^p
ll  GCD(ll  a,ll  b){ while(b){b ^= a ^=b ^= a %=b;}  return a;}
ll  LCM(ll  a,ll  b) { return (a / GCD(a,b)*b); }
ll  BigMod(ll  B,ll  P,ll  M){ ll  R=1; while(P>0)  {if(P&1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return (ll )R;} //compute b^p%m
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//int i=uniform_int_distribution<int>(1,n)(rng);
///-----------------------------------------------------------------------------

ll n,d,m,t;
vll v1 = {0},v2={0};

///-----------------------------------------------------------------------------
int main()
{
    #ifndef ONLINE_JUDGE
//       freopen( "output.txt" , "w" , stdout ) ;
    //   freopen( "input.txt" , "r" , stdin ) ;
    auto stTime = clock();
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
//    cout.tie(0);
///-----------------------------------------------------------------------------------

    cin >> n >> d >> m;

    lp(i,0,n){
        cin >> t;
        if(t <= m) v1.push_back(t);
        else v2.push_back(t);
    }
    sort(v1.begin()+1,v1.end(),greater<ll>());
    sort(v2.begin()+1,v2.end(),greater<ll>());
    lp(i,1,v1.size()) v1[i] += v1[i-1];
    lp(i,1,v2.size()) v2[i] += v2[i-1];

    ll ans = 0;

    lp(i,1,v2.size()){
        int pos = n - (i-1) * (d+1) -1;
        if(pos < 0 ){
            if(0LL-pos + i >= (ll)v2.size() ) continue;
            else pos = 0;
        }
        if(pos >= v1.size()){
            pos = n-(i)*(d+1)-1;
            if(pos < v1.size()-1) pos = v1.size()-1;
            else continue;
        }
        ans = max(ans,v1[pos]+v2[i]);
    }
    if(v2.size()==1) ans = v1[v1.size()-1];

    cout << ans;
///------------------------------------------------------------------------------------
    #ifndef ONLINE_JUDGE
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int OO = 0x3f3f3f3f;
//const long long OO = (long long) 1e18L+7;
//const unsigned long long UOO = (long long) 10e18+7;
#define lp(i,a,n) for(int i = a ; i < n ; ++i)
#define lpr(i,a,n) for(int i = a ; i >= n ; --i)
#define rep(i,vec) for(int i = 0 ; i < vec.size() ; ++i)
#define reprv(i,vec) for(int i = vec.size()-1; i >=0 ; --i)
#define eps (1e-5)
#define pb(i) push_back(i)
#define EPS 1e-9
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define debug(x) cout<<(#x)<<": \""<<x<<"\""<<endl
#define debugVec(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl

typedef vector<int> vi ;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll ;
typedef pair<int,int> pii ;
typedef vector< pair<int,int> >  vpii;
typedef vector<pair<long long,long long>> vpll;
typedef vector<vector<int> > vvi ;
typedef complex<double> point;
typedef pair<ll,ll> pll;

ll  inv(ll a, ll b) {return 1 < a ? b - inv(b % a, a) * b / a : 1;}
ll  Pow(ll  B,ll  P){ll  R=1; while(P>0)  {if(P&1) R=(R*B);P/=2;B=(B*B);}return R;} //compute b^p
ll  GCD(ll  a,ll  b){ while(b){b ^= a ^=b ^= a %=b;}  return a;}
ll  LCM(ll  a,ll  b) { return (a / GCD(a,b)*b); }
ll  BigMod(ll  B,ll  P,ll  M){ ll  R=1; while(P>0)  {if(P&1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return (ll )R;} //compute b^p%m
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//int i=uniform_int_distribution<int>(1,n)(rng);
///-----------------------------------------------------------------------------

ll n,d,m,t;
vll v1 = {0},v2={0};

///-----------------------------------------------------------------------------
int main()
{
    #ifndef ONLINE_JUDGE
//       freopen( "output.txt" , "w" , stdout ) ;
    //   freopen( "input.txt" , "r" , stdin ) ;
    auto stTime = clock();
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
//    cout.tie(0);
///-----------------------------------------------------------------------------------

    cin >> n >> d >> m;

    lp(i,0,n){
        cin >> t;
        if(t <= m) v1.push_back(t);
        else v2.push_back(t);
    }
    sort(v1.begin()+1,v1.end(),greater<ll>());
    sort(v2.begin()+1,v2.end(),greater<ll>());
    lp(i,1,v1.size()) v1[i] += v1[i-1];
    lp(i,1,v2.size()) v2[i] += v2[i-1];

    ll ans = 0;

    lp(i,1,v2.size()){
        int pos = n - (i-1) * (d+1) -1;
        if(pos < 0 ){
            if(0LL-pos + i >= (ll)v2.size() ) continue;
            else pos = 0;
        }
        if(pos >= v1.size()){
            continue;
            pos = n-(i)*(d+1)-1;
            if(pos < v1.size()) pos = v1.size()-1;
            else continue;
        }
        ans = max(ans,v1[pos]+v2[i]);
    }
    if(v2.size()==1) ans = v1[v1.size()-1];

    cout << ans;
///------------------------------------------------------------------------------------
    #ifndef ONLINE_JUDGE
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int OO = 0x3f3f3f3f;
//const long long OO = (long long) 1e18L+7;
//const unsigned long long UOO = (long long) 10e18+7;
#define lp(i,a,n) for(int i = a ; i < n ; ++i)
#define lpr(i,a,n) for(int i = a ; i >= n ; --i)
#define rep(i,vec) for(int i = 0 ; i < vec.size() ; ++i)
#define reprv(i,vec) for(int i = vec.size()-1; i >=0 ; --i)
#define eps (1e-5)
#define pb(i) push_back(i)
#define EPS 1e-9
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define debug(x) cout<<(#x)<<": \""<<x<<"\""<<endl
#define debugVec(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl

typedef vector<int> vi ;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll ;
typedef pair<int,int> pii ;
typedef vector< pair<int,int> >  vpii;
typedef vector<pair<long long,long long>> vpll;
typedef vector<vector<int> > vvi ;
typedef complex<double> point;
typedef pair<ll,ll> pll;

ll  inv(ll a, ll b) {return 1 < a ? b - inv(b % a, a) * b / a : 1;}
ll  Pow(ll  B,ll  P){ll  R=1; while(P>0)  {if(P&1) R=(R*B);P/=2;B=(B*B);}return R;} //compute b^p
ll  GCD(ll  a,ll  b){ while(b){b ^= a ^=b ^= a %=b;}  return a;}
ll  LCM(ll  a,ll  b) { return (a / GCD(a,b)*b); }
ll  BigMod(ll  B,ll  P,ll  M){ ll  R=1; while(P>0)  {if(P&1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return (ll )R;} //compute b^p%m
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//int i=uniform_int_distribution<int>(1,n)(rng);
///-----------------------------------------------------------------------------

ll n,d,m,t;
vll v1,v2;

///-----------------------------------------------------------------------------
int main()
{
    #ifndef ONLINE_JUDGE
//       freopen( "output.txt" , "w" , stdout ) ;
    //   freopen( "input.txt" , "r" , stdin ) ;
    auto stTime = clock();
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
//    cout.tie(0);
///-----------------------------------------------------------------------------------

    cin >> n >> d >> m;
    lp(i,0,n){
        cin >> t;
        if(t <= m) v1.push_back(t);
        else v2.push_back(t);
    }
    sort(all(v1),greater<ll>());
    sort(all(v2),greater<ll>());
    lp(i,1,v1.size()) v1[i] += v1[i-1];
    lp(i,1,v2.size()) v2[i] += v2[i-1];
    ll ans = 0;
    lp(i,0,v2.size()){
        int pos = n - (i)*(d+1) - 2;
//        cout << v2[i] << " " << (i)*(d+1)+1 << "\n";
        if(pos < 0 || pos >= v1.size()) continue;
        ans = max(ans,v2[i] + v1[pos]);
    }

    cout << ans;
///------------------------------------------------------------------------------------
    #ifndef ONLINE_JUDGE
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int OO = 0x3f3f3f3f;
//const long long OO = (long long) 1e18L+7;
//const unsigned long long UOO = (long long) 10e18+7;
#define lp(i,a,n) for(int i = a ; i < n ; ++i)
#define lpr(i,a,n) for(int i = a ; i >= n ; --i)
#define rep(i,vec) for(int i = 0 ; i < vec.size() ; ++i)
#define reprv(i,vec) for(int i = vec.size()-1; i >=0 ; --i)
#define eps (1e-5)
#define pb(i) push_back(i)
#define EPS 1e-9
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define debug(x) cout<<(#x)<<": \""<<x<<"\""<<endl
#define debugVec(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl

typedef vector<int> vi ;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll ;
typedef pair<int,int> pii ;
typedef vector< pair<int,int> >  vpii;
typedef vector<pair<long long,long long>> vpll;
typedef vector<vector<int> > vvi ;
typedef complex<double> point;
typedef pair<ll,ll> pll;

ll  inv(ll a, ll b) {return 1 < a ? b - inv(b % a, a) * b / a : 1;}
ll  Pow(ll  B,ll  P){ll  R=1; while(P>0)  {if(P&1) R=(R*B);P/=2;B=(B*B);}return R;} //compute b^p
ll  GCD(ll  a,ll  b){ while(b){b ^= a ^=b ^= a %=b;}  return a;}
ll  LCM(ll  a,ll  b) { return (a / GCD(a,b)*b); }
ll  BigMod(ll  B,ll  P,ll  M){ ll  R=1; while(P>0)  {if(P&1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return (ll )R;} //compute b^p%m
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//int i=uniform_int_distribution<int>(1,n)(rng);
///-----------------------------------------------------------------------------

ll n,d,m,t;
vll v1,v2;

///-----------------------------------------------------------------------------
int main()
{
    #ifndef ONLINE_JUDGE
//       freopen( "output.txt" , "w" , stdout ) ;
    //   freopen( "input.txt" , "r" , stdin ) ;
    auto stTime = clock();
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
//    cout.tie(0);
///-----------------------------------------------------------------------------------

    cin >> n >> d >> m;
    lp(i,0,n){
        cin >> t;
        if(t <= m) v1.push_back(t);
        else v2.push_back(t);
    }
    sort(all(v1),greater<ll>());
    sort(all(v2),greater<ll>());
    lp(i,1,v1.size()) v1[i] += v1[i-1];
    lp(i,1,v2.size()) v2[i] += v2[i-1];
    ll ans = 0;
    lp(i,0,v2.size()){
        int pos = n - (i)*(d+1) - 2;
//        cout << v2[i] << " " << (i)*(d+1)+1 << "\n";
        if(pos < 0 || pos >= v1.size()) continue;
         ans = max(ans,v2[i] + v1[pos]);
    }
    if(v2.size()==0) ans = v1[v1.size()-1];

    cout << ans;
///------------------------------------------------------------------------------------
    #ifndef ONLINE_JUDGE
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int OO = 0x3f3f3f3f;
//const long long OO = (long long) 1e18L+7;
//const unsigned long long UOO = (long long) 10e18+7;
#define lp(i,a,n) for(int i = a ; i < n ; ++i)
#define lpr(i,a,n) for(int i = a ; i >= n ; --i)
#define rep(i,vec) for(int i = 0 ; i < vec.size() ; ++i)
#define reprv(i,vec) for(int i = vec.size()-1; i >=0 ; --i)
#define eps (1e-5)
#define pb(i) push_back(i)
#define EPS 1e-9
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define debug(x) cout<<(#x)<<": \""<<x<<"\""<<endl
#define debugVec(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl

typedef vector<int> vi ;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll ;
typedef pair<int,int> pii ;
typedef vector< pair<int,int> >  vpii;
typedef vector<pair<long long,long long>> vpll;
typedef vector<vector<int> > vvi ;
typedef complex<double> point;
typedef pair<ll,ll> pll;

ll  inv(ll a, ll b) {return 1 < a ? b - inv(b % a, a) * b / a : 1;}
ll  Pow(ll  B,ll  P){ll  R=1; while(P>0)  {if(P&1) R=(R*B);P/=2;B=(B*B);}return R;} //compute b^p
ll  GCD(ll  a,ll  b){ while(b){b ^= a ^=b ^= a %=b;}  return a;}
ll  LCM(ll  a,ll  b) { return (a / GCD(a,b)*b); }
ll  BigMod(ll  B,ll  P,ll  M){ ll  R=1; while(P>0)  {if(P&1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return (ll )R;} //compute b^p%m
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//int i=uniform_int_distribution<int>(1,n)(rng);
///-----------------------------------------------------------------------------

ll n,d,m,t;
vll v1 = {0},v2={0};

///-----------------------------------------------------------------------------
int main()
{
    #ifndef ONLINE_JUDGE
//       freopen( "output.txt" , "w" , stdout ) ;
    //   freopen( "input.txt" , "r" , stdin ) ;
    auto stTime = clock();
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
//    cout.tie(0);
///-----------------------------------------------------------------------------------

    cin >> n >> d >> m;

    lp(i,0,n){
        cin >> t;
        if(t <= m) v1.push_back(t);
        else v2.push_back(t);
    }
    sort(v1.begin()+1,v1.end(),greater<ll>());
    sort(v2.begin()+1,v2.end(),greater<ll>());
    lp(i,1,v1.size()) v1[i] += v1[i-1];
    lp(i,1,v2.size()) v2[i] += v2[i-1];

    ll ans = 0;

    lp(i,1,v2.size()){
        int pos = n - (i-1) * (d+1) -1;
        if(pos < 0 ){
            if(0LL-pos + i > (ll)v2.size() ) break;
            else pos = 0;
        }
        if(pos >= v1.size()){
            pos = n-(i)*(d+1)-1;
            if(pos < v1.size()) pos = v1.size()-1;
            else continue;
        }
        ans = max(ans,v1[pos]+v2[i]);
    }
    if(v2.size()==1) ans = v1[v1.size()-1];

    cout << ans;
///------------------------------------------------------------------------------------
    #ifndef ONLINE_JUDGE
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int OO = 0x3f3f3f3f;
//const long long OO = (long long) 1e18L+7;
//const unsigned long long UOO = (long long) 10e18+7;
#define lp(i,a,n) for(int i = a ; i < n ; ++i)
#define lpr(i,a,n) for(int i = a ; i >= n ; --i)
#define rep(i,vec) for(int i = 0 ; i < vec.size() ; ++i)
#define reprv(i,vec) for(int i = vec.size()-1; i >=0 ; --i)
#define eps (1e-5)
#define pb(i) push_back(i)
#define EPS 1e-9
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define debug(x) cout<<(#x)<<": \""<<x<<"\""<<endl
#define debugVec(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl

typedef vector<int> vi ;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll ;
typedef pair<int,int> pii ;
typedef vector< pair<int,int> >  vpii;
typedef vector<pair<long long,long long>> vpll;
typedef vector<vector<int> > vvi ;
typedef complex<double> point;
typedef pair<ll,ll> pll;

ll  inv(ll a, ll b) {return 1 < a ? b - inv(b % a, a) * b / a : 1;}
ll  Pow(ll  B,ll  P){ll  R=1; while(P>0)  {if(P&1) R=(R*B);P/=2;B=(B*B);}return R;} //compute b^p
ll  GCD(ll  a,ll  b){ while(b){b ^= a ^=b ^= a %=b;}  return a;}
ll  LCM(ll  a,ll  b) { return (a / GCD(a,b)*b); }
ll  BigMod(ll  B,ll  P,ll  M){ ll  R=1; while(P>0)  {if(P&1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return (ll )R;} //compute b^p%m
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//int i=uniform_int_distribution<int>(1,n)(rng);
///-----------------------------------------------------------------------------

ll n,d,m,t;
vll v1,v2;

///-----------------------------------------------------------------------------
int main()
{
    #ifndef ONLINE_JUDGE
//       freopen( "output.txt" , "w" , stdout ) ;
    //   freopen( "input.txt" , "r" , stdin ) ;
    auto stTime = clock();
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
//    cout.tie(0);
///-----------------------------------------------------------------------------------

    cin >> n >> d >> m;
    lp(i,0,n){
        cin >> t;
        if(t <= m) v1.push_back(t);
        else v2.push_back(t);
    }
    sort(all(v1),greater<ll>());
    sort(all(v2),greater<ll>());
    lp(i,1,v1.size()) v1[i] += v1[i-1];
    lp(i,1,v2.size()) v2[i] += v2[i-1];
    ll ans = 0;
    lp(i,0,v2.size()){
        int pos = min(n - (i)*(d+1) - 2,(ll)v1.size()-1);
//        cout << v2[i] << " " << (i)*(d+1)+1 << "\n";
        if(pos < 0 || pos >= v1.size()) continue;
        ans = max(ans,v2[i] + v1[pos]);
    }

    cout << ans;
///------------------------------------------------------------------------------------
    #ifndef ONLINE_JUDGE
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define R(i,b,a) for(int i=(int)(b);i>=(int)(a);i--)
#define endl "\n"
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define out(x) cout<<setprecision(15)<<x<<endl,exit(0)
#define pii pair<int,int>
#define pb push_back
#define all(v) v.begin(),v.end()
#define I first
#define S second
#define ld long double
ld pi=3.14159265359;

int32_t main(){
	ios;
	int n,d,m;
	cin>>n>>d>>m;

	vector <int> u,v;
	F(i,1,n){
		int x;
		cin>>x;
		if(x>m) v.pb(x);
		else u.pb(x);
	}

	if(v.size()==0) out(accumulate(all(u),0ll));

	sort(all(u),greater<int>());
	sort(all(v),greater<int>());

	int y=(v.size()/(d+1))+(v.size()%(d+1)!=0);
	int z=(n/(d+1))+(n%(d+1)!=0);
	z=min(z,(int)(v.size()));

	F(i,1,v.size()-1) v[i]+=v[i-1];
	F(i,1,u.size()-1) u[i]+=u[i-1];

	//cout<<y<<" "<<z<<endl;
	int mx=0;
	F(i,y,z){
		int tmp=(i-1)*(d+1)+1;
		if(n-tmp-1>=0 && n-tmp<=u.size()) mx=max(mx,v[i-1]+u[n-tmp-1]);
	}
	cout<<mx;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define R(i,b,a) for(int i=(int)(b);i>=(int)(a);i--)
#define endl "\n"
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define out(x) cout<<setprecision(15)<<x<<endl,exit(0)
#define pii pair<int,int>
#define pb push_back
#define all(v) v.begin(),v.end()
#define I first
#define S second
#define ld long double
ld pi=3.14159265359;

int32_t main(){
	ios;
	int n,d,m;
	cin>>n>>d>>m;

	vector <int> u,v;
	F(i,1,n){
		int x;
		cin>>x;
		if(x>m) v.pb(x);
		else u.pb(x);
	}

	if(v.size()==0) out(accumulate(all(u),0ll));

	sort(all(u),greater<int>());
	sort(all(v),greater<int>());

	int y=(v.size()/(d+1))+(v.size()%(d+1)!=0);

	F(i,1,v.size()-1) v[i]+=v[i-1];
	F(i,1,u.size()-1) u[i]+=u[i-1];

	//cout<<y<<" "<<v.size()<<endl;
	int mx=0;
	F(i,y,v.size()){
		int val,tmp=(i-1)*(d+1)+1;
		if(tmp>n) continue;

		tmp=n-tmp-1;

		if(tmp>(int)(u.size())-1){
			val=u.back();
		}
		else if(tmp<0){
			val=0;
		}
		else val=u[tmp];
		mx=max(mx,v[i-1]+val);
	}
	cout<<mx;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define R(i,b,a) for(int i=(int)(b);i>=(int)(a);i--)
#define endl "\n"
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define out(x) cout<<setprecision(15)<<x<<endl,exit(0)
#define pii pair<int,int>
#define pb push_back
#define all(v) v.begin(),v.end()
#define I first
#define S second
#define ld long double
ld pi=3.14159265359;

int32_t main(){
	ios;
	int n,d,m;
	cin>>n>>d>>m;

	vector <int> u,v;
	F(i,1,n){
		int x;
		cin>>x;
		if(x>m) v.pb(x);
		else u.pb(x);
	}

	if(v.size()==0) out(accumulate(all(u),0ll));

	sort(all(u),greater<int>());
	sort(all(v),greater<int>());

	int y=(v.size()/(d+1))+(v.size()%(d+1)!=0);
	int z=(n/(d+1))+(n%(d+1)!=0);

	F(i,1,v.size()-1) v[i]+=v[i-1];
	F(i,1,u.size()-1) u[i]+=u[i-1];

	int mx=0;
	F(i,y,z){
		int tmp=(i-1)*(d+1)+1;
		if(n-tmp-1>=0) mx=max(mx,v[i-1]+u[n-tmp-1]);
	}
	cout<<mx;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define R(i,b,a) for(int i=(int)(b);i>=(int)(a);i--)
#define endl "\n"
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define out(x) cout<<setprecision(15)<<x<<endl,exit(0)
#define pii pair<int,int>
#define pb push_back
#define all(v) v.begin(),v.end()
#define I first
#define S second
#define ld long double
ld pi=3.14159265359;

int32_t main(){
	ios;
	int n,d,m;
	cin>>n>>d>>m;

	vector <int> u,v;
	F(i,1,n){
		int x;
		cin>>x;
		if(x>m) v.pb(x);
		else u.pb(x);
	}

	sort(all(u),greater<int>());
	sort(all(v),greater<int>());

	int y=(n/(d+1))+(n%(d+1)!=0);
	int z=n-(y-1)*(d+1)-1;

	int ans=0;
	if(v.size()>y){
		F(i,1,y) ans+=v[i-1];
	}
	else{
		ans=accumulate(all(v),0ll);
		if(v.size()) z=(v.size()-1)*d+v.size();
		else z=0;
		F(i,1,n-z) ans+=u[i-1];
	}
	cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define R(i,b,a) for(int i=(int)(b);i>=(int)(a);i--)
#define endl "\n"
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define out(x) cout<<setprecision(15)<<x<<endl,exit(0)
#define pii pair<int,int>
#define pb push_back
#define all(v) v.begin(),v.end()
#define I first
#define S second
#define ld long double
ld pi=3.14159265359;

int32_t main(){
	ios;
	int n,d,m;
	cin>>n>>d>>m;

	vector <int> u,v;
	F(i,1,n){
		int x;
		cin>>x;
		if(x>m) v.pb(x);
		else u.pb(x);
	}

	if(v.size()==0) out(accumulate(all(u),0ll));

	sort(all(u),greater<int>());
	sort(all(v),greater<int>());

	int y=(v.size()/(d+1))+(v.size()%(d+1)!=0);
	int z=(n/(d+1))+(n%(d+1)!=0);

	F(i,1,v.size()-1) v[i]+=v[i-1];
	F(i,1,u.size()-1) u[i]+=u[i-1];

	//cout<<y<<" "<<z<<endl;
	int mx=0;
	F(i,y,z){
		int tmp=(i-1)*(d+1)+1;
		if(n-tmp-1>=0 && n-tmp<=u.size()) mx=max(mx,v[i-1]+u[n-tmp-1]);
	}
	cout<<mx;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define R(i,b,a) for(int i=(int)(b);i>=(int)(a);i--)
#define endl "\n"
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define out(x) cout<<setprecision(15)<<x<<endl,exit(0)
#define pii pair<int,int>
#define pb push_back
#define all(v) v.begin(),v.end()
#define I first
#define S second
#define ld long double
ld pi=3.14159265359;

int32_t main(){
	ios;
	int n,d,m;
	cin>>n>>d>>m;

	vector <int> u,v;
	F(i,1,n){
		int x;
		cin>>x;
		if(x>m) v.pb(x);
		else u.pb(x);
	}

	if(v.size()==0) out(accumulate(all(u),0ll));

	sort(all(u),greater<int>());
	sort(all(v),greater<int>());

	int y=(v.size()/(d+1))+(v.size()%(d+1)!=0);

	F(i,1,v.size()-1) v[i]+=v[i-1];
	F(i,1,u.size()-1) u[i]+=u[i-1];

	//cout<<y<<" "<<z<<endl;
	int mx=0;
	F(i,y,v.size()){
		int val,tmp=(i-1)*(d+1)+1;
		if(tmp>n) continue;
		if(tmp>u.size()) val=u.back();
		else val=u[n-tmp-1];
		mx=max(mx,v[i-1]+val);
	}
	cout<<mx;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define R(i,b,a) for(int i=(int)(b);i>=(int)(a);i--)
#define endl "\n"
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define out(x) cout<<setprecision(15)<<x<<endl,exit(0)
#define pii pair<int,int>
#define pb push_back
#define all(v) v.begin(),v.end()
#define I first
#define S second
#define ld long double
ld pi=3.14159265359;

int32_t main(){
	ios;
	int n,d,m,mx=0;
	cin>>n>>d>>m;

	vector <int> u,v;
	F(i,1,n){
		int x;
		cin>>x;
		if(x>m) v.pb(x);
		else u.pb(x),mx+=x;
	}

	sort(all(u),greater<int>());
	sort(all(v),greater<int>());
	if(v.size()) mx+=v[0];

	int cur=mx;
	F(i,1,v.size()-1){
		if(u.size()<d) break;

		F(j,1,d){
			cur-=u.back();
			u.pop_back();
		}
		cur+=v[i];
		mx=max(mx,cur);
	}
	cout<<mx;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define R(i,b,a) for(int i=(int)(b);i>=(int)(a);i--)
#define endl "\n"
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define out(x) cout<<setprecision(15)<<x<<endl,exit(0)
#define pii pair<int,int>
#define pb push_back
#define all(v) v.begin(),v.end()
#define I first
#define S second
#define ld long double
ld pi=3.14159265359;

int32_t main(){
	ios;
	int n,d,m;
	cin>>n>>d>>m;

	vector <int> u,v;
	F(i,1,n){
		int x;
		cin>>x;
		if(x>m) v.pb(x);
		else u.pb(x);
	}

	if(v.size()==0) out(accumulate(all(u),0ll));

	sort(all(u),greater<int>());
	sort(all(v),greater<int>());

	int y=(v.size()/(d+1))+(v.size()%(d+1)!=0);
	int z=(n/(d+1))+(n%(d+1)!=0);

	F(i,1,v.size()-1) v[i]+=v[i-1];
	F(i,1,u.size()-1) u[i]+=u[i-1];

	int mx=0;
	F(i,y,z){
		int tmp=(i-1)*(d+1)+1;
		mx=max(mx,v[i-1]+u[n-tmp-1]);
	}
	cout<<mx;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define R(i,b,a) for(int i=(int)(b);i>=(int)(a);i--)
#define endl "\n"
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define out(x) cout<<setprecision(15)<<x<<endl,exit(0)
#define pii pair<int,int>
#define pb push_back
#define all(v) v.begin(),v.end()
#define I first
#define S second
#define ld long double
ld pi=3.14159265359;

int32_t main(){
	ios;
	int n,d,m;
	cin>>n>>d>>m;

	vector <int> u,v;
	F(i,1,n){
		int x;
		cin>>x;
		if(x>m) v.pb(x);
		else u.pb(x);
	}

	if(v.size()==0) out(accumulate(all(u),0ll));

	sort(all(u),greater<int>());
	sort(all(v),greater<int>());

	int y=(v.size()/(d+1))+(v.size()%(d+1)!=0);

	F(i,1,v.size()-1) v[i]+=v[i-1];
	F(i,1,u.size()-1) u[i]+=u[i-1];

	//cout<<y<<" "<<z<<endl;
	int mx=0;
	F(i,y,v.size()){
		int tmp=(i-1)*(d+1)+1;
		if(tmp>n) continue;
		mx=max(mx,v[i-1]+u[n-tmp-1]);
	}
	cout<<mx;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define R(i,b,a) for(int i=(int)(b);i>=(int)(a);i--)
#define endl "\n"
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define out(x) cout<<setprecision(15)<<x<<endl,exit(0)
#define pii pair<int,int>
#define pb push_back
#define all(v) v.begin(),v.end()
#define I first
#define S second
#define ld long double
ld pi=3.14159265359;

int32_t main(){
	ios;
	int n,d,m;
	cin>>n>>d>>m;

	vector <int> u,v;
	F(i,1,n){
		int x;
		cin>>x;
		if(x>m) v.pb(x);
		else u.pb(x);
	}

	sort(all(u),greater<int>());
	sort(all(v),greater<int>());

	int y=(n/(d+1))+(n%(d+1)!=0);
	int z=n-(y-1)*(d+1)-1;

	int ans=0;
	if(v.size()>=y){
		F(i,1,z) ans+=u[i-1];
		F(i,1,y) ans+=v[i-1];
	}
	else{
		ans=accumulate(all(v),0ll);
		if(v.size()) z=(v.size()-1)*d+v.size();
		else z=0;
		F(i,1,n-z) ans+=u[i-1];
	}
	cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define R(i,b,a) for(int i=(int)(b);i>=(int)(a);i--)
#define endl "\n"
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define out(x) cout<<setprecision(15)<<x<<endl,exit(0)
#define pii pair<int,int>
#define pb push_back
#define all(v) v.begin(),v.end()
#define I first
#define S second
#define ld long double
ld pi=3.14159265359;

int32_t main(){
	ios;
	int n,d,m;
	cin>>n>>d>>m;

	vector <int> u,v;
	F(i,1,n){
		int x;
		cin>>x;
		if(x>m) v.pb(x);
		else u.pb(x);
	}

	if(v.size()==0) out(accumulate(all(u),0ll));

	sort(all(u),greater<int>());
	sort(all(v),greater<int>());

	int y=(v.size()/(d+1))+(v.size()%(d+1)!=0);

	F(i,1,v.size()-1) v[i]+=v[i-1];
	F(i,1,u.size()-1) u[i]+=u[i-1];

	//cout<<y<<" "<<v.size()<<endl;
	int mx=0;
	F(i,y,v.size()){
		int val,tmp=(i-1)*(d+1)+1;
		if(tmp>n) continue;

		tmp=n-tmp-1;
		if(u.size()==0) val=0;
		else if(tmp>(int)(u.size())-1){
			val=u.back();
		}
		else if(tmp<0){
			val=0;
		}
		else val=u[tmp];
		mx=max(mx,v[i-1]+val);
	}
	cout<<mx;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define R(i,b,a) for(int i=(int)(b);i>=(int)(a);i--)
#define endl "\n"
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define out(x) cout<<setprecision(15)<<x<<endl,exit(0)
#define pii pair<int,int>
#define pb push_back
#define all(v) v.begin(),v.end()
#define I first
#define S second
#define ld long double
ld pi=3.14159265359;

int32_t main(){
	ios;
	int n,d,m;
	cin>>n>>d>>m;

	vector <int> u,v;
	F(i,1,n){
		int x;
		cin>>x;
		if(x>m) v.pb(x);
		else u.pb(x);
	}

	if(v.size()==0) out(accumulate(all(u),0ll));

	sort(all(u),greater<int>());
	sort(all(v),greater<int>());

	int y=(v.size()/(d+1))+(v.size()%(d+1)!=0);

	F(i,1,v.size()-1) v[i]+=v[i-1];
	F(i,1,u.size()-1) u[i]+=u[i-1];

	//cout<<y<<" "<<z<<endl;
	int mx=0;
	F(i,y,v.size()){
		int val,tmp=(i-1)*(d+1)+1;
		if(tmp>n) continue;

		tmp=n-tmp;
		if(tmp>u.size()) val=u.back();
		else val=u[n-tmp-1];
		mx=max(mx,v[i-1]+val);
	}
	cout<<mx;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define R(i,b,a) for(int i=(int)(b);i>=(int)(a);i--)
#define endl "\n"
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define out(x) cout<<setprecision(15)<<x<<endl,exit(0)
#define pii pair<int,int>
#define pb push_back
#define all(v) v.begin(),v.end()
#define I first
#define S second
#define ld long double
ld pi=3.14159265359;

int32_t main(){
	ios;
	int n,d,m;
	cin>>n>>d>>m;

	vector <int> u,v;
	F(i,1,n){
		int x;
		cin>>x;
		if(x>m) v.pb(x);
		else u.pb(x);
	}

	if(v.size()==0) out(accumulate(all(u),0ll));

	sort(all(u),greater<int>());
	sort(all(v),greater<int>());

	int y=(v.size()/(d+1))+(v.size()%(d+1)!=0);

	F(i,1,v.size()-1) v[i]+=v[i-1];
	F(i,1,u.size()-1) u[i]+=u[i-1];

	//cout<<y<<" "<<z<<endl;
	int mx=0;
	F(i,y,v.size()){
		int val,tmp=(i-1)*(d+1)+1;
		if(tmp>n) continue;

		tmp=n-tmp;
		if(tmp>u.size()) val=u.back();
		else val=u[tmp-1];
		mx=max(mx,v[i-1]+val);
	}
	cout<<mx;
}