2 1
1 1
 4 1
2 2 1 1
 10 1
2 6 3 4 2 4 4 3 2 1
 2 1
999152 999153
 8 1000000
1 1 5 1000000 1000000 2 2 2
 9 2
1 6 1 5 5 8 6 8 7
 15 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 1 4
8
 10 1
6 3 1 3 6 4 1 3 6 4
 10 1
1 2 3 5 6 8 10 11 9 4
 7 2
1 5 5 8 9 8 8
 2 1000000
1 1000000
 8 2
3 13 9 8 3 13 9 14
 1 1
1
 2 1
1 2

2
 2
 4
 1
 2
 4
 15
 1
 7
 2
 4
 1
 5
 1
 1

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

typedef long double lld;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll MAXN=1e6+5;
const int N=3e5+5;
const ll mod = 1e9+ 7;
//const ll mx=1e16;


#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);
#define tc long long t; scanf("%lld\n",&t); while(t--)
#define f(ii,jj,nn) for(ll ii=jj;ii<nn;ii++)
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld %lld",&x,&y)
#define slll(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define pl(x) printf("%lld\n",x)
#define pf(x) printf("x\n")
#define mp(x,y) make_pair(x,y)
#define CLEAR(a) memset(a,0,sizeof(a))
#define eb(x) pop_back(x)
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define si(x) scanf("%d",&x)
#define pi(x) printf("%d\n",x)
#define sii(x,y) scanf("%d%d",&x,&y)
#define siii(x,y,z) scanf("%d%d%d",&x,&y,&z)

#define trace1(x)			     cout <<x<<endl;
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
bool comp(const int a,const int b){return a>b;}
const double PI= 2*acos(0.0);

//---------------------------------------------------------------------------
ll fac[N],POWER[65];
void pre() {fac[0] = 1LL;f(i,1,N) {fac[i] = 1LL*i*fac[i - 1];if(fac[i] >= mod) fac[i] %= mod;}}
ll power(ll a, ll b) {ll x = 1;while(b) {if(b&1) {x *= a;if(x >= mod) x %= mod;}a *= a;if(a >= mod) a %= mod;b >>= 1;} return x;}
ll inv(ll k) {return power(k, mod - 2);}
ll lcm(ll a, ll b){return a * (b / __gcd(a, b));}
ll gcd(ll a, ll b) {if(!b) return a;return gcd(b,a%b);}
string inttostrng(ll n){ ostringstream str1;str1 << n;string ans = str1.str();return ans;}
ll strngtoint(string s){stringstream geek(s);ll x = 0;geek >> x;return x;}
void precompute(){POWER[0]=1;for(int i=1;i<63;i++) POWER[i]=POWER[i-1]<<1LL;}
//-------------------------------------------------------------------------------------------------------------------------------
int main(){
    vector<int> v;
    int n,ans=INT16_MIN,k;
    cin >> n >> k;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a,a+n,greater<int>());
    v.pb(a[0]);
    int j=0;
    for(int i=1;i<n;i++){
        
        while(j<i &&  (a[j]>a[i]+k || a[j]==a[i]) )
        {
            j++;
        }
        if(a[j]<=a[i]+k && a[j]>a[i] && j!=i)
        continue;
        if(j==i){
            v.pb(a[i]);
        }
    }
    f(i,0,v.size()){
        cout << v[i] << " ";
    }
}

 