Loading two ships

N containers with the given weights are loaded one by one, each onto ship A or ship B. Ship A can carry at most CA and ship B at most CB. When everything is loaded, the difference between the two ships' totals must be less than D. Count the ways to load the containers, modulo 10^9 + 7.

Reported in: Infosys (SP / DSE · 22 Nov 2026) (memory-based)

Input

First line: N. Second line: N weights. Third line: CA CB D.

Output

The number of ways modulo 10^9 + 7.

Constraints

1 ≤ N ≤ 100; 1 ≤ weights ≤ 1000; 1 ≤ CA, CB ≤ 10^5; 1 ≤ D ≤ 10^5.

Example 1

Input:
3
1 2 3
4 4 1

Output:
2

Example 2

Input:
4
2 2 2 2
6 6 3

Output:
6

Example 3

Input:
2
5 1
3 10 100

Output:
2

Hint: Loads only grow, so the capacity limits just have to hold at the end. Let ways[a] be the number of ways to load the first i containers with ship A carrying a (ship B carries the rest); then add up the a whose difference from the other ship is under D.

All coding practice