**Problem Description**

**Input**

The input may contain several data sets. Each data set contains three lines. First line contains the months of the project planed to use which is no more than 12. The second line contains the cost of hiring a worker, the amount of the salary, the cost of firing a worker. The third line contains several numbers (between 1 to 16), which represent the minimal number of the workers needed each month. The input is terminated by line containing a single '0'.

**Output**

The output contains one line. The minimal total cost of the project.

**Sample Input**

3 4 5 6 10 9 11 0

**Sample Output**

199

**Source**

Asia 1997, Shanghai (Mainland China)