#include<bits/stdc++.h>
using namespace std;
#define mod 1e18
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 9223372036854775807
#define mini 9223372036854775807
ll A[500005];
ll tree[2000005];
void update(ll node, ll start, ll end, ll idx, ll val)
{
    if(start == end)
    {
        A[idx] += val;
        tree[node] += val;
    }
    else
    {
        ll mid = (start + end) / 2;
        if(start <= idx and idx <= mid)
        {
            update(2*node, start, mid, idx, val);
        }
        else
        {
            update(2*node+1, mid+1, end, idx, val);
        }
        tree[node] = tree[2*node] + tree[2*node+1];
    }
}
ll query(ll node, ll start, ll end, ll l, ll r)
{
    if(r < start or end < l)
    {
        return 0;
    }
    if(l <= start and end <= r)
    {
        return tree[node];
    }
    ll mid = (start + end) / 2;
    ll p1 = query(2*node, start, mid, l, r);
    ll p2 = query(2*node+1, mid+1, end, l, r);
    return (p1 + p2);
}
int main()
{
	boost
	ll n,k;
	cin>>n>>k;
	ll a[n];
	pair<ll,ll>p[n];
	ll c[n];
	for(ll i=0; i<n; i++)
	{
		cin>>a[i];
		p[i]=mp(a[i],i);
	}
	sort(p,p+n);
	ll b[n];
	for(ll i=0; i<n; i++)
	{
		b[p[i].se]=i;
		c[i]=p[i].fi;
	}	
	for(ll i=n-1; i>=0; i--)
	{
		ll ub=upper_bound(c,c+n,a[i]+k)-c;
		ub--;
		ll lb=lower_bound(c,c+n,a[i]-k)-c;
		ll xxx=query(1,0,n,lb,ub);
		xxx%=mod;
		xxx++;
		xxx%=mod;
		update(1,0,n,b[i],xxx);
	}
	ll ans=query(1,0,n,0,n);
	ans%=mod;
	cout<<ans<<endl;
	return 0;
}