Problem:
Score : 1100 points

Problem Statement

There is a set consisting of N distinct integers. The i-th smallest element in this set is S_i. We want to divide this set into two sets, X and Y, such that:

The absolute difference of any two distinct elements in X is A or greater.

The absolute difference of any two distinct elements in Y is B or greater.

How many ways are there to perform such division, modulo 10^9 + 7? Note that one of X and Y may be empty.

Constraints

All input values are integers.

1 ≦ N ≦ 10^5

1 ≦ A , B ≦ 10^{18}

0 ≦ S_i ≦ 10^{18}(1 ≦ i ≦ N)

S_i < S_{i+1}(1 ≦ i ≦ N - 1)

Input

The input is given from Standard Input in the following format:

N A B
S_1
:
S_N

Output

Print the number of the different divisions under the conditions, modulo 10^9 + 7.

Sample Input 1

5 3 7
1
3
6
9
12

Sample Output 1

5

There are five ways to perform division:

X={1,6,9,12}, Y={3}

X={1,6,9}, Y={3,12}

X={3,6,9,12}, Y={1}

X={3,6,9}, Y={1,12}

X={3,6,12}, Y={1,9}

Sample Input 2

7 5 3
0
2
4
7
8
11
15

Sample Output 2

4

Sample Input 3

8 2 9
3
4
5
13
15
22
26
32

Sample Output 3

13

Sample Input 4

3 3 4
5
6
7

Sample Output 4

0

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct BIT {
  vector<int> data;
  BIT(int n):data(n+1, 0){}
  int sum(int k) {
    int ret = 0;
    while(k > 0) {
      ret += data[k];
      ret %= mod;
      k -= k & -k;
    }
    return ret;
  }
  int sum(int l, int r) {
    return (sum(r)-sum(l-1)+mod)%mod;
  }
  void add(int k, int x) {
    while(k < (int)data.size()) {
      data[k] += x;
      data[k] %= mod;
      k += k & -k;
    }
  }
};

int dp[100010];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, A, B;
  cin >> N >> A >> B;
  if(A > B) swap(A, B);
  vint S(N+1);
  S[0] = -inf;
  reps(i, 1, N+1) cin >> S[i];

  rep(i, N-1) {
    if(S[i+2]-S[i] < A) {
      cout << 0 << endl;
      return 0;
    }
  }

  BIT bit(N+1);
  int l = 0, r = 0;
  dp[0] = 1;
  bit.add(1, 1);
  reps(i, 1, N+1) {
    while(S[i]-S[r] >= B) ++r;
    //assert(l < r);
    if(l <= r) dp[i] = bit.sum(l+1, r);
    bit.add(i+1, dp[i]);
    if(S[i]-S[i-1] < A) l = i-1;
  }
  if(l <= N) dp[N] += bit.sum(l+1, N); // X
  dp[N] %= mod;
  cout << dp[N] << endl;

  return 0;
}