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 <stdio.h>
#include <bits/stdc++.h>			

#define pb push_back
#define pf push_front
#define pp pop_back
#define sz(a) (int)(a.size())
#define mp make_pair
#define F first
#define S second
#define next _next
#define prev _prev
#define left _left
#define right _right
#define y1 _y1
#define all(x) x.begin(), x.end()
#define what_is(x) #x << " is " << (x)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = (int)1e6 + 123;
const ll INF = (ll)1e18 + 123;
const int inf = (int)1e9 + 123;
const int MOD = (int)1e9 + 7;

void megaRandom() {
	unsigned int FOR;
 	asm("rdtsc" : "=A"(FOR));
  srand(FOR);
}

int n;
ll s[N], A, B;
int dp[N];

int add(int a, int b) {
	a += b;
	if(a >= MOD) a -= MOD;
	return a;
}

int subs(int a, int b) {
	a -= b;
	if(a < 0) a += MOD;
	return a;
} 

bool ok[25][N];
int pref[N];
int Log[N];

bool check(int l, int r) {
	if(l > r) 
		return 0;
	assert(l <= r);
	if(l == r) return 1;
	int Log2 = Log[r - l + 1];
	return (ok[Log2][l] & ok[Log2][r - (1 << Log2) + 1]);
}

int get_sum(int l, int r) {
	if(l > r) return 0;
	if(!l) return pref[r];
	return subs(pref[r], pref[l - 1]);
}

int main() {
	megaRandom();
	scanf("%d%lld%lld", &n, &A, &B);
	//scanf("%d", &n);
	for(int i = 1; i <= n; i ++) 
		scanf("%lld", &s[i]);
	if(A > B) swap(A, B);
	//assert(n <= 10000);
	s[0] = -INF;
	for(int i = 0; i <= n; i ++)
		ok[0][i] = s[i];
	for(int it = 1; it <= 20; it ++) {
		for(int i = 0; i + (1 << it) - 1 <= n; i ++) {
			bool can = ((s[i + (1 << (it - 1))] - s[i + (1 << (it - 1)) - 1]) >= A);
			ok[it][i] = (ok[it - 1][i] & ok[it - 1][i + (1 << (it - 1))] & can);			
		}
	}
	Log[1] = 0;
	for(int i = 2; i <= N - 123; i ++) {
		Log[i] = Log[i - 1];
		while((1 << (Log[i] + 1)) <= i)
			Log[i] ++;
	}
	//cout << ok[1][0];
	/*int q;
	scanf("%d", &q);
	for(int i = 1; i <= q; i ++) {
		int l, r;
		scanf("%d%d", &l, &r);
		if(check(l, r)) puts("GOOD");
		else puts("BAD");

	}
	return 0;   */
	dp[0] = 1;
	pref[0] = 1;
	for(int i = 1; i <= n; i ++) {
		pref[i] = pref[i - 1];
		int ps1 = 0, ps2 = 0;
		int ql = 0, qr = i;
		while(qr - ql > 1) {
			int mid = (ql + qr) >> 1;
			if(s[i] - s[mid] >= B)
				ql = mid;
			else 
				qr = mid;
		}
		ps1 = ql;		
		ql = 0, qr = i - 1;
		while(qr - ql > 1) {
			int mid = (ql + qr) >> 1;
			if(check(mid, i - 1))
				qr = mid;
			else 
				ql = mid;
		}
		if(check(ql, i - 1)) qr = ql;
		ps2 = qr;
		if(ps1 + 1 < ps2) 
			continue;		
		if(ps2 == 1) {
			assert(check(1, i - 1));
			ps2 = 0;
		}
		dp[i] = add(dp[i], get_sum(ps2, ps1));
		if((ps2 >= 2 && s[ps2] - s[ps2 - 2] >= A))
			dp[i] = add(dp[i], dp[ps2 - 1]);
		pref[i] = add(pref[i], dp[i]);
	}
	int res = 0;
	for(int i = n; i >= 0; i --) {
		if(i == 0 || i == n || (s[i + 1] - s[i - 1] >= A))
			res = add(res, dp[i]);
		if(i != n && s[i + 1] - s[i] < A)
			break;
	}
	printf("%d", res);
	return 0; 
}