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)

#define ENABLE_DEBUG 0
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/
// mint{{{
template <class ModType> struct modint {
    using value_type = typename ModType::value_type;
    using mint = modint<ModType>;
    using mod_type = ModType;

    static value_type mod() { return ModType::value; }

    private:
    static value_type inverse(value_type x) {
        value_type y=1,u=mod(),v=0;
        while(x){
            value_type q=u/x;
            u-=q*x; std::swap(x,u);
            v-=q*y; std::swap(y,v);
        }
        assert(x==0 && std::abs(y)==mod() && std::abs(u)==1 && std::abs(v)<mod());
        return v<0?v+mod():v;
    }

    public:
    // the member variable
    value_type value;

    // constructors
    modint()=default;
    modint(modint const&)=default;
    modint(modint&&)=default;
    modint& operator=(modint const&)=default;
    modint& operator=(modint&&)=default;
    ~modint()=default;

    template <class T> modint(T t) : value([t] () mutable {
            if ( t <= -static_cast<T>(mod()) || static_cast<T>(mod()) <= t ) t %= mod();
            return t < 0 ? t + mod() : t;
            }()) {}

    // operators
    mint& operator+= (mint y) {
        value += y.value;
        if (mod() <= value) value -= mod();
        return *this;
    }

    mint& operator-= (mint y) {
        value -= y.value;
        if ( value < 0 ) value += mod();
        return *this;
    }

    mint& operator*= (mint y) {
        value = (long long)value * y.value % mod();
        return *this;
    }

    mint& operator/= (mint y) {
        value = (long long)value * inverse(y.value) % mod();
        return *this;
    }

    mint& operator++() { return *this+=1; }
    mint& operator--() { return *this-=1; }
    mint operator++(int) { mint this_=*this; ++*this; return this_; }
    mint operator--(int) { mint this_=*this; --*this; return this_; }
    mint operator-() const { return 0 - *this; }

    // static member functions
    static mint inv(mint x) { return inverse(x.value); }

    static mint m1pow(long long y) { return y%2?-1:1; }

    static mint pow(mint x, unsigned long long y) {
        mint ans=1;
        for(;y;y>>=1){
            if(y&1ull) ans*=x;
            x*=x;
        }
        return ans;
    }

    // non-member functions
    mint& add_assign(mint y) { return *this+=y; }
    mint& sub_assign(mint y) { return *this-=y; }
    mint& mul_assign(mint y) { return *this*=y; }
    mint& div_assign(mint y) { return *this/=y; }
    mint& inv_assign()       { return *this = inv(*this); }
    mint& pow_assign(unsigned long long y){ return *this = pow(*this, y); }

    mint add(mint y) const { mint ans=*this; return ans.add_assign(y); }
    mint sub(mint y) const { mint ans=*this; return ans.sub_assign(y); }
    mint mul(mint y) const { mint ans=*this; return ans.mul_assign(y); }
    mint div(mint y) const { mint ans=*this; return ans.div_assign(y); }
    mint inv()       const { mint ans=*this; return ans.inv_assign(); }
    mint pow(unsigned long long y) const { return pow(*this, y); }
    mint square(mint x) const { return *this * *this; }
    mint cube(mint x) const { return *this * *this * *this; }

    template <class F> mint map(F const& f){
        value=f(value);
        return *this;
    }
};

template <class T> std::istream&
operator>>(std::istream& is, modint<T>& x) {
    typename modint<T>::value_type y;
    is >> y;
    x = modint<T>{ y };
    return is;
}
template <class T> std::ostream&
operator<<(std::ostream& os, modint<T> x) {
    return os << x.value;
}

template <class T> modint<T> operator+(modint<T> x, modint<T> y) { return x+=y; }
template <class T> modint<T> operator-(modint<T> x, modint<T> y) { return x-=y; }
template <class T> modint<T> operator*(modint<T> x, modint<T> y) { return x*=y; }
template <class T> modint<T> operator/(modint<T> x, modint<T> y) { return x/=y; }
template <class T> bool operator==(modint<T> x, modint<T> y) { return x.value==y.value; }
template <class T> bool operator!=(modint<T> x, modint<T> y) { return x.value!=y.value; }

template <class T, class U> modint<T> operator+(modint<T> x, U y) { return x+modint<T>(y); }
template <class T, class U> modint<T> operator-(modint<T> x, U y) { return x-modint<T>(y); }
template <class T, class U> modint<T> operator*(modint<T> x, U y) { return x*modint<T>(y); }
template <class T, class U> modint<T> operator/(modint<T> x, U y) { return x/modint<T>(y); }
template <class T, class U> bool operator==(modint<T> x, U y) { return x==modint<T>(y); }
template <class T, class U> bool operator!=(modint<T> x, U y) { return x!=modint<T>(y); }

template <class T, class U> modint<T> operator+(U x, modint<T> y) { return modint<T>(x)+y; }
template <class T, class U> modint<T> operator-(U x, modint<T> y) { return modint<T>(x)-y; }
template <class T, class U> modint<T> operator*(U x, modint<T> y) { return modint<T>(x)*y; }
template <class T, class U> modint<T> operator/(U x, modint<T> y) { return modint<T>(x)/y; }
template <class T, class U> bool operator==(U x, modint<T> y) { return modint<T>(x)==y; }
template <class T, class U> bool operator!=(U x, modint<T> y) { return modint<T>(x)!=y; }
/*}}}*/
using mint = modint<std::integral_constant<i64, 1'000'000'007>>;
// segtree{{{
template <class Monoid>
struct segtree {
    using value_type = typename Monoid::value_type;

    std::vector<value_type> table;

    segtree()=default;
    segtree(segtree const&)=default;
    segtree(segtree&&)=default;
    segtree&operator=(segtree const&)=default;
    segtree&operator=(segtree&&)=default;

    segtree(std::size_t n, value_type init=Monoid::id())
        : table(2*n, init) {}

    void resize(std::size_t n, value_type init=Monoid::id()) {
        assert(table.empty());
        table.resize(2*n, init);
    }

    void lazy_set(std::size_t i, value_type x) {
        table.at(i + size()) = x;
    }

    void build() {
        for (std::size_t i=size()-1; i; i--) {
            table.at(i) = Monoid::op(table.at(2*i), table.at(2*i+1));
        }
    }

    std::size_t size() const { return table.size() / 2; }

    value_type fold(std::size_t l, std::size_t r) const {
        value_type fl = Monoid::id();
        value_type fr = Monoid::id();

        for(l+=size(),r+=size();l<r;l>>=1,r>>=1){
            if(l&1u) fl=Monoid::op(fl, table.at(l++));
            if(r&1u) fr=Monoid::op(fr, table.at(--r));
        }

        return Monoid::op(fl, fr);
    }

    value_type get(std::size_t i) const { return table.at(size() + i); }

    std::vector<value_type> to_vec() const {
        std::vector<value_type> ret(size());
        std::copy(table.begin()+size(), table.end(), ret.begin());
        return ret;
    }

    void set(std::size_t i, value_type x) {
        assert(i < size());
        i+=size();
        table.at(i) = x;
        for (i>>=1; i; i>>=1) {
            table.at(i) = Monoid::op(table.at(2*i), table.at(2*i+1));
        }
    }

    void add(std::size_t i, value_type x) { set(i, get(i) + x); }
    void sub(std::size_t i, value_type x) { set(i, get(i) - x); }
    void mul(std::size_t i, value_type x) { set(i, get(i) * x); }
    void div(std::size_t i, value_type x) { set(i, get(i) / x); }

    template <class F> void map(std::size_t i, F const& f) { set(i, f(get(i))); }
};
/*}}}*/
template <class Value> struct add_monoid_t {
    using value_type = Value;
    static value_type op(value_type l, value_type r) { return l + r; }
    static const value_type id() { return 0; }
};
template <usize N, class T, class... Args, std::enable_if_t<N==0, int> = 0>
auto mkvec(Args... args) {
    return T(args...);
}
template <usize N, class T, class... Args, std::enable_if_t<N!=0, int> = 0>
auto mkvec(usize sz, Args... args) {
    using value_type = std::decay_t<decltype(mkvec<N-1, T>(args...))>;
    return vec<value_type>(sz, mkvec<N-1, T>(args...));
}
int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    i64 inf = numr<i64>::max();

    i64 n;
    vec<i64> d(2);
    std::cin >> n >> d.at(0) >> d.at(1);
    vec<i64> a(n+2);
    DEBUG(n, d);
    a.at(0) = a.at(1) = -inf;
    for (i64 i=2; i<n+2; i++) std::cin >> a.at(i);
    n += 2;
    DEBUG(skipinf(a, -inf));

    auto prv = mkvec<2, i64>(2, n);
    for (i64 ph=0; ph<2; ph++) {
        auto&& v = prv.at(ph);
        v.at(0) = 0;
        for (i64 i=1; i<n; i++) {
            v.at(i) = a.at(i-1) + d.at(ph) <= a.at(i) ? v.at(i-1) : i;
        }
    }
    DEBUG(matrix_style(prv));

    vec<i64> left(2);
    auto seg = vec<segtree<add_monoid_t<mint>>>(2, segtree<add_monoid_t<mint>>(n));
    seg.at(1).set(0, 1);
    for (i64 i=2; i<n; i++) {
        DEBUG(i);
        for (i64 ph=0; ph<2; ph++) {
            i64 nl = std::min((i64)(std::upper_bound(ALL(a), a.at(i) - d.at(ph)) - a.begin()), i - 1);
            seg.at(ph).add(i-1, seg.at(!ph).fold(0, nl));
        }
        for (i64 ph=0; ph<2; ph++) {
            i64 nl = prv.at(ph).at(i)-1;
            for (i64 j=left.at(ph); j<nl; j++) {
                DEBUG("erase", j);
                seg.at(ph).set(j, 0);
            }
            left.at(ph) = nl;
        }
        DEBUG(seg.at(0).to_vec());
        DEBUG(seg.at(1).to_vec());
    }

    mint ans = seg.at(0).fold(0, n) + seg.at(1).fold(0, n);
    std::cout << ans << '\n';
}

/*
 * 先頭にマイナス無限の赤色確定、青色確定の番兵を一つずつ、合計 2 ついれて、残りを塗ることにしましょう。
 *
 * dp[0][i][j] = 長さ i + 1 で、終端が赤色で、青色の中でもっとも後ろのものが j なものの個数。
 * dp[1][i][j] = 長さ i + 1 で、終端が青色で、赤色の中でもっとも後ろのものが j なものの個数。
 *
 * 貰う DP で考えると、
 * dp[0][i][j] = (dp[0][i-1][j] or 0) if j < i - 1
 * dp[0][i][i-1] = dp[1][i-1][ 区間 ] の和
 * のようになります。
 *
 * ひとつめは、前のものとの差が A 以上ならば 0 と書いていないほうの選択肢です。
 * ふたつめの区間は、今の所と A 以上差のある部分かつ、添字が i-2 以下の部分です。
 *
 * さて、この配列を使いまわしましょう。
 * 意味有りげな更新のある箇所は一箇所で、dp[0][i][i-1] ですね。
 * これは、区間和の取れるデータ構造を使うと良いです。
 *
 * しかし、意味のなさげな（←失礼でしょう）更新がたくさんあります。
 * 前のものと癒着している場合は、「全消し」が行われます。悲しいですね。
 * これは、どこまでが消えているのかを覚えておくと良いです。
 * 区間更新もできるデータ構造（遅延セグツリーなど）を使うという手もあります。
 */