Tire Patches

On a circular tire, cover all hole positions with the minimum total length of uncut patches of two given lengths and return that total length.

Hard8Dynamic programmingArrayGreedySortingInterviewNo attempts yetTime limit2sMemory limit512 MB

Problem

Carlos cares about the environment, so he takes the least polluting transport he can. He recently took a job close to home and now rides his bike to work.

The trouble is that the road between his home and his job passes a nail factory. Nails fall off the trucks often, and they puncture the tires of Carlos' bike. He therefore has to put several patches on those tires.

Carlos uses two types of patch. Both are as wide as the tire and differ only in length. The price of a patch is proportional to its length, so Carlos wants the total length of the patches he uses to be as small as possible, and he never cuts a patch.

A repair starts with a chalk mark at one point of the tire. Carlos then writes down the distance from that mark to each hole, measured clockwise. Every hole must be completely covered by one patch. A patch can be placed anywhere along the tire, either type can be used any number of times, and patches may overlap. Given the positions of the holes, find the cheapest repair.

Input

The first line contains four integers NN, CC, T1T_1 and T2T_2. Here NN is the number of holes in the tire and CC is the length of the tire's circumference. The lengths of the two patches are T1T_1 and T2T_2. All lengths are in centimetres. The second line contains NN integers F1,F2,,FNF_1, F_2, \dots, F_N, where FiF_i is the distance from the chalk mark to hole ii measured clockwise.

Restrictions

  • 1N10001 \le N \le 1000
  • 1C1061 \le C \le 10^6
  • 1T1,T2C1 \le T_1, T_2 \le C
  • 0FiC10 \le F_i \le C - 1 (1iN1 \le i \le N)
  • If the distance between two holes is exactly kk centimetres, one patch of length kk centimetres covers both holes.
  • Two different holes may sit at the same position.

Output

Print a single line with one integer, the smallest total length of patches needed to cover every hole.