D - Web Service Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

問題文

あなたはあるWebサービスの機能を一年間利用しようとしています。
まず、あなたは会員登録を行い、無料会員、一般会員、プレミアム会員のいずれかになる必要があります。

  • 無料会員には無料でなれます。無料会員は毎月 3 回まで無料で機能を利用できますが、4 回目以降は利用のたびに A 円を支払う必要があります。
  • 一般会員になるには登録時に一年分の会費として B 円を支払う必要があります。一般会員は毎月 50 回まで無料で機能を利用できますが、51 回目以降は利用のたびに A 円を支払う必要があります。
  • プレミアム会員になるには登録時に一年分の会費として C 円を支払う必要があります。プレミアム会員は何回でも無料で機能を利用できます。

あなたは i=1,2,\ldots,12 に対し、今月から数えて i 番目の月に x_i 回機能を利用することが分かっています。
会員登録と機能の利用で支払うことになる合計金額の最小値を求めてください。

制約

  • 1 \leq A \leq 1000
  • 1 \leq B \lt C \leq 1000
  • 1 \leq x_i \leq 1000
  • 入力はすべて整数

入力

入力は以下の形式で標準入力から与えられる。

A B C
x_1 \ldots x_{12}

出力

答えが X 円のとき、X を整数として出力せよ。


入力例 1

5 20 30
1 2 3 4 5 6 7 8 9 10 11 12

出力例 1

20

無料会員になると、1,2,3 月は 3 回までしか機能を利用しないので支払いが必要ありませんが、4 月以降は 4 回以上利用するのでそれぞれ 1,2,\ldots,9A 円の支払いが発生し、合計で 225 円支払うことになります。
一般会員になると、初めに一年分の会費として 20 円を支払う必要がありますが、どの月も機能を 50 回以下しか利用しないためこれ以外の支払いはありません。
プレミアム会員になると、初めに一年分の会費として 30 円を支払う必要があります。プレミアム会員は何回でも無料で機能を利用できるので、これ以外の支払いはありません。
以上より、一般会員になった場合に支払う 20 円が最小です。


入力例 2

5 20 30
100 100 100 100 100 100 100 100 100 100 100 100

出力例 2

30

入力例 3

1 999 1000
50 50 50 50 50 50 50 50 50 50 50 50

出力例 3

564

Problem Statement

You are going to use a feature of a web service for a year.
First of all, you must sign up to become a free member, a standard member, or a premium member.

  • You can become a free member with no charge. A free member can use the feature at most three times a month, but subsequent usage costs A yen each time.
  • To become a standard member, you need to pay an annual fee of B yen on registration. A standard member can use the feature up to 50 times a month, with each additional use costing A yen.
  • To become a premium member, you need to pay an annual fee of C yen on registration. A premium member can use the feature any number of times for free.

For i=1,2,\ldots,12, you are going to use the feature x_i times in the i-th month.
Find the minimum total cost required for the registration and using the feature.

Constraints

  • 1 \leq A \leq 1000
  • 1 \leq B \lt C \leq 1000
  • 1 \leq x_i \leq 1000
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

A B C
x_1 \ldots x_{12}

Output

If the answer is X yen, print the integer X.


Sample Input 1

5 20 30
1 2 3 4 5 6 7 8 9 10 11 12

Sample Output 1

20

Suppose that you become a free member. In the first three months, you will use the features at most three times a month, and no payment is required; for the remaining months, you will use it more than three times a month, so you need to pay A yen once, twice, \ldots, and nine times, for a total of 225 yen.
Now consider becoming a standard member. You need to pay the annual fee of 20 yen on registration, but you will use the feature no more than 50 times a month, so no further payment is required.
If you become a premium member, you first need to pay an annual fee of 30 yen. But a premium member can use the feature as many times as they want, so no more payment is required.
Therefore, the minimum cost is 20 yen, when you become a standard member.


Sample Input 2

5 20 30
100 100 100 100 100 100 100 100 100 100 100 100

Sample Output 2

30

Sample Input 3

1 999 1000
50 50 50 50 50 50 50 50 50 50 50 50

Sample Output 3

564