#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize( \
    "O3,Ofast,unroll-loops,no-stack-protector,fast-math,inline")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,popcnt,lzcnt,mmx,abm,avx,avx2,tune=native")
const long long mod = 1e9 + 7;
class Solution {
 public:
  vector<long long> v;
  long long getId(long long x) {
    return lower_bound(v.begin(), v.end(), x) - v.begin() + 1;
  }
  struct SegTree {
    vector<long long> seg;
    void init(long long n) { seg.resize(4 * n, 0); }
    void update(long long node, long long start, long long end, long long pos,
                long long val) {
      if (start == end) {
        seg[node] += val % mod;
        seg[node] %= mod;
        return;
      }
      long long mid = (start + end) >> 1;
      if (pos <= mid) {
        update(2 * node, start, mid, pos, val);
      } else {
        update(2 * node + 1, mid + 1, end, pos, val);
      }
      seg[node] = (seg[2 * node] + seg[2 * node + 1]) % mod;
    }
    long long query(long long node, long long start, long long end, long long L,
                    long long R) {
      if (start > R or end < L) {
        return 0;
      }
      if (start >= L and end <= R) {
        return seg[node];
      }
      long long mid = (start + end) >> 1;
      return (query(2 * node, start, mid, L, R) +
              query(2 * node + 1, mid + 1, end, L, R)) %
             mod;
    }
  };
  long long solve(vector<long long>& nums, long long k) {
    long long n = (long long)(nums.size());
    v = nums;
    sort(v.begin(), v.end());
    ((v).erase(unique((v).begin(), (v).end()), (v).end()));
    vector<long long> old_nums = nums;
    for (long long i = 0; i < n; ++i) {
      nums[i] = getId(nums[i]);
    }
    SegTree S;
    S.init(n);
    long long ans = 0;
    for (long long i = 0; i < n; ++i) {
      long long L = getId(old_nums[i] - k);
      long long R =
          upper_bound(v.begin(), v.end(), old_nums[i] + k) - v.begin();
      long long curr = 1 + S.query(1, 1, n, L, R);
      curr %= mod;
      ans += curr;
      ans %= mod;
      S.update(1, 1, n, nums[i], curr);
    }
    return ans;
  }
};
int32_t main() {
  long long n, k;
  cin >> n >> k;
  vector<long long> v;
  for (long long i = 0; i < n; ++i) {
    long long x;
    cin >> x;
    v.push_back(x);
  }
  Solution s;
  cout << s.solve(v, k);
  return 0;
}
