Time limit
2s
Memory limit
128 MB
Jungmoon is holding a birthday party for D days. Friends will attend the party, and Jungmoon plans to play with toys every day. On day i, exactly Ti toys are needed.
A toy shop sells one toy for Tc 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 N1 days, and the cost is C1 won per toy. If a toy is left at the second facility at night, it can be picked up in the morning after N2 days, and the cost is C2 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.
The first line contains six integers D, N1, N2, C1, C2, and Tc.
Each of the next D lines contains one integer Ti, the number of toys needed on day i.
Print the minimum cost required to complete all birthday party days.