cho.sh
Notes
Loading...

Toy Sterilization

Time limit

2s

Memory limit

128 MB

Problem

Jungmoon is holding a birthday party for DDD days. Friends will attend the party, and Jungmoon plans to play with toys every day. On day iii, exactly TiT_iTi​ toys are needed.

A toy shop sells one toy for TcT_cTc​ won. A toy that has already been used cannot be used again as-is; only a new toy or a toy that has finished sterilization may be used.

Jungmoon can use two sterilization facilities. If a toy is left at the first facility at night, it can be picked up in the morning after N1N_1N1​ days, and the cost is C1C_1C1​ won per toy. If a toy is left at the second facility at night, it can be picked up in the morning after N2N_2N2​ days, and the cost is C2C_2C2​ won per toy.

Jungmoon may buy toys as needed and send used toys to the sterilization facilities. Find the minimum total cost required to complete all party days.

Input

The first line contains six integers DDD, N1N_1N1​, N2N_2N2​, C1C_1C1​, C2C_2C2​, and TcT_cTc​.

Each of the next DDD lines contains one integer TiT_iTi​, the number of toys needed on day iii.

Output

Print the minimum cost required to complete all birthday party days.

Constraints

  • 1≤D≤100 0001 \le D \le 100\,0001≤D≤100000
  • 1≤N1,N2≤D1 \le N_1, N_2 \le D1≤N1​,N2​≤D
  • 1≤C1,C2≤601 \le C_1, C_2 \le 601≤C1​,C2​≤60
  • 1≤Tc≤601 \le T_c \le 601≤Tc​≤60