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 <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define INF 1000000007LL
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,n_;
ll a,b;
ll s[100001];
ll dp[100001][2];
ll dat[1<<20];

void add(int k,ll a){
	k+=n_-1;
	dat[k]=a;
	while(k>0){
		k=(k-1)/2;
		dat[k]=min(dat[k*2+1],dat[k*2+2]);
	}
}

ll query(ll a,ll b,int k=0,int l=0,int r=n_){
	if(b<=l || r<=a)return INF;
	if(a<=l && r<=b)return dat[k];
	ll vl=query(a,b,k*2+1,l,(l+r)/2);
	ll vr=query(a,b,k*2+2,(l+r)/2,r);
	return min(vl,vr);
}

ll func(int v,int prev){
	if(dp[v][prev]!=-1)return dp[v][prev];
	if(v>=n)return 1LL;
	ll res=0;
	if(v==0){
		res=func(1,0);
		int nexa=lower_bound(s,s+n,s[v]+b)-s;
		if(nexa==v+1){
			res+=func(v+1,1);
		}else if(nexa==v+2){
			res+=func(v+2,0);
		}else if(query(v+1,nexa-1)>=a){
			res+=func(nexa,0);
		}
	}else{
		if(prev==0){
			if(s[v-1]+a<=s[v]){
				res=func(v+1,0);
			}
			int nexa=lower_bound(s,s+n,s[v]+b)-s;
			bool flag2=true;
			if(v!=n-1){
				if(nexa!=v+1 && s[v-1]+a>s[v+1]){
					flag2=false;
				}
			}
			if(nexa==v+1){
				res+=func(v+1,1);
			}else if(nexa==v+2){
				if(flag2)res+=func(v+2,0);
			}else if(query(v+1,nexa-1)>=a){
				if(flag2)res+=func(nexa,0);
			}
		}else{
			if(s[v-1]+b<=s[v]){
				res=func(v+1,1);
			}
			res+=func(v+1,0);
		}
	}
	return (dp[v][prev]=(res%MOD));
}

bool flag[100001];
int main(void){
	scanf("%d%lld%lld",&n,&a,&b);
	n_=1;
	while(n_<n)n_*=2;
	if(a>b)swap(a,b);
	for(int i=0;i<n;i++){
		scanf("%lld",&s[i]);
	}
	for(int i=0;i<n-1;i++){
		add(i,s[i+1]-s[i]);
	}
	memset(flag,false,sizeof(flag));
	for(int i=0;i<n-2;i++){
		if(s[i]+b>s[i+1] && s[i]+a>s[i+2]){
			flag[i]=true;
		}
	}
	memset(dp,-1,sizeof(dp));
	printf("%lld\n",func(0,0));
	return 0;
}