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: Accepted)

#include<bits/stdc++.h>
#define mo 1000000007
#define plus(a,b) (a+b<mo)?(a+=b):(a+=b-mo) 
using namespace std;
int n;
long long d[1000100];
struct bit
{
	int sum[1000100];
	vector <int> vec;
	void clear()
	{
		for (int i=0;i<vec.size();i++) sum[vec[i]]=0;
		vec.clear();
	}
	void add(int s,int w)
	{s++;if (!w) return;
		while (s<=n+1)
		{
			plus(sum[s],w);vec.push_back(s);
			s+=s&(-s);
		}
	}
	int getsum(int s)
	{s++;
		int ans=0;
		while (s)
		{
			plus(ans,sum[s]);
			s-=s&(-s);
		}
		return ans;
	}
	int getsum(int l,int r)
	{
		int p=getsum(l-1),q=getsum(r);
		if (p<=q) return q-p;else return q-p+mo;
	}
}f,g;
int main()
{
	long long a,b;scanf("%d%lld%lld",&n,&a,&b);
	for (int i=1;i<=n;i++) scanf("%lld",&d[i]);
	f.add(0,1);g.add(0,1);
	int tf=0,tg=0;
	for (int i=2;i<=n;i++)
	{
		while ((tf+1<i)&&(d[i]-d[tf+1]>=a)) tf++;
		while ((tg+1<i)&&(d[i]-d[tg+1]>=b)) tg++;
		int ff=g.getsum(tf),gg=f.getsum(tg);
		if (d[i]-d[i-1]>=a) f.add(i-1,ff);
		else {f.clear();f.add(i-1,ff);}
	 	if (d[i]-d[i-1]>=b) g.add(i-1,gg);
	 	else {g.clear();g.add(i-1,gg);}
	}
	printf("%d\n",(f.getsum(n-1)+g.getsum(n-1))%mo);
}