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 <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second
#define endl "\n"

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<int, int> P;


class modInt{
    ll value;
    static const ll mod = 1000000007;

public:
    modInt(ll x=0): value{x % mod}{}

    inline modInt& operator+=(modInt x){
        value = (value + x.value) % mod;
        return *this;
    }

    inline modInt& operator-=(modInt x){
        value = (value + mod - x.value) % mod;
        return *this;
    }

    inline modInt& operator*=(modInt x){
        value = (value * x.value) % mod;
        return *this;
    }


    inline modInt operator/=(modInt x){
        *this *= x.inv();
        return *this;
    }

    inline modInt pow(modInt x, int n){
        modInt res = modInt(1LL);
        while(n > 0){
            if(n & 1)   res *= x;
            x *= x;
            n >>= 1;
        }
        return res;
    }

    inline modInt inv(){
        modInt res = pow(value, mod-2);
        return res;
    }

    inline ll get(){
        return value;
    }
};

modInt operator+(modInt x, modInt y){
    return x += y;
}

modInt operator-(modInt x, modInt y){
    return x -= y;
}

modInt operator*(modInt x, modInt y){
    return x *= y;
}

modInt operator/(modInt x, modInt y){
    return x /= y;
}

ostream& operator<<(ostream& os, modInt x){
    return os << x.get();
}


class modIntCombinations{
    vector<modInt> factArray;

    void make_fact(ll x){
        for(auto i = factArray.size(); i <= x+1; i++){
            modInt y = factArray[i-1] * i;
            factArray.push_back(y);
        }
    }

public:
    modIntCombinations(){
        factArray.emplace_back(1);
    }

    modInt fact(ll x){
        if(factArray.size() < x+1){
            make_fact(x);
        }
        return factArray[x];
    }

    modInt comb(ll n, ll k){
        if(n < k){
            return modInt{0};
        }
        else{
            return fact(n) / fact(k) / fact(n - k);
        }
    }

    modInt perm(ll n, ll k){
        if(n < k){
            return modInt{0};
        }
        else{
            return fact(n) / fact(k);
        }
    }
};


template <typename T>
class SegmentTree {
private:
    using F = function<T(T, T)>;
    int n, sz;
    vector<T> node;
    T u;
    F f;

    T query(int a, int b, int i, int l, int r) {
        if(r <= a || b <= l) {
            return u;
        }
        else if(a <= l && r <= b) {
            return node[i];
        }
        else {
            T vl = query(a, b, 2 * i + 1, l, (l + r) / 2);
            T vr = query(a, b, 2 * i + 2, (l + r) / 2, r);
            return f(vl, vr);
        }
    }

public:
    /**
     *
     * @param v  初期配列
     * @param func  nodeに対する操作
     * @param u2  Tの単位元
     */
    SegmentTree(vector<T> &v, const F func, T u2) : f(func), u(u2) {
        sz = v.size();
        n = 1;
        while(n < sz) {
            n *= 2;
        }
        node.resize(2 * n - 1, u2);
        for(int i = 0; i < sz; i++) {
            node[i + n - 1] = v[i];
        }
        for(int i = n - 2; i >= 0; i--) {
            node[i] = f(node[2 * i + 1], node[2 * i + 2]);
        }
    }

    void update(int i, T val) {
        i += (n - 1);
        node[i] = val;
        while(i > 0) {
            i = (i - 1) / 2;
            node[i] = f(node[2 * i + 1], node[2 * i + 2]);
        }
    }

    T query(int l, int r){
        return query(l, r, 0, 0, n);
    }

    T operator[](const int &i) const { return node[i + n - 1]; }
};



int main(){
    int n; ll a, b; cin >> n >> a >> b;
    vector<ll> s(n);
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }
    for(int i = 2; i < n; i++){
        if(((s[i] - s[i-1] < a) && (s[i] - s[i-2] < b)) || ((s[i] - s[i-1] < b) && (s[i] - s[i-2] < a))){
            cout << 0 << endl;
            return 0;
        }
    }

    vector<modInt> init_vector(n, modInt{0});
    vector<SegmentTree<modInt>> seg(2, SegmentTree<modInt>(init_vector,
                                                           [](modInt x, modInt y){ return x + y; }, modInt{0}));

    seg[0].update(0, modInt{1});
    seg[1].update(0, modInt{1});

    for(int i = 1; i < n; i++){
        if(seg[0][i-1].get() == 0 && seg[1][i-1].get() == 0){
            cout << 0 << endl;
            return 0;
        }
        modInt res = seg[0][i-1] + seg[1][i-1];

        int index1 = lower_bound(s.begin(), s.end(), s[i] - a + 1) - s.begin();
        int index2 = lower_bound(s.begin(), s.end(), s[i] - b + 1) - s.begin();

        modInt sub1 = seg[0].query(index1, i);
        modInt sub2 = seg[1].query(index2, i);

        seg[0].update(i, res - sub1);
        seg[1].update(i, res - sub2);
    }

    cout << seg[0][n-1] + seg[1][n-1] << endl;



    return 0;
}