cho.sh
Notes
Loading...

Surprise Gift Delivery

Time limit

2s

Memory limit

128 MB

Problem

Jungyu prepared surprise gifts for Dohyun. Since he no longer feels brave enough to hand them over directly, he wants to leave one gift at each place Dohyun often visits.

All of those places and the warehouse that stores the gifts lie on the same straight line. Each place is given by its distance from the warehouse.

Jungyu can use a truck to move gifts. The truck can carry at most A gifts at a time. Driving the truck costs B won per kilometer, regardless of how many gifts are loaded. Initially, the truck is at the warehouse.

A gift can be delivered only while the truck is parked. Each parking stop costs C won, but stopping at the warehouse to load gifts is free. The truck may be parked at any position. Gifts cannot be thrown out while the truck is moving.

From a parked truck, Jungyu may also carry gifts on foot. While walking, he can carry only one gift at a time. Walking 1 km while carrying a gift costs D won, and walking with empty hands is free.

Given the number of gifts, their required positions, the truck capacity A, the driving cost B, the parking cost C, and the walking cost D, compute the minimum total cost needed to deliver every gift. After all gifts are delivered, the truck does not have to return to the warehouse.

Input

The first line contains N, the number of positions where gifts must be delivered. (1 <= N <= 50)

The second line contains the distances between the warehouse and the required delivery positions. Each distance is an integer from 1 to 1,000,000, measured in kilometers.

The third line contains four integers A, B, C, and D. (1 <= A <= 50, 0 <= B, C, D <= 1,000,000)

Output

Print the minimum cost needed to deliver all gifts.

Hint

In the first visible test, all gifts are loaded and the truck is driven to distance 2, where it parks. The gift for distance 2 is delivered there. Then one gift is carried on foot to distance 1, and after returning empty-handed, another gift is carried to distance 3. The total cost is 13.