Dohna Dohna
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 1024 M,其他语言2048 M
64bit IO Format: %lld

题目描述

Toilet-Ares got tired of playing traditional FPS games. Therefore, he started to play Dohna Dohna --- a brand new type of FPS game.


In this game, Kuma (the main character) is going to defeat  enemies in a queue, where the -th enemy from the beginning of the queue has health point h_i. Once an enemy's health point drops to 0 or lower, he will be knocked out from the queue.

Due to technical issues, Kuma and his team can only damage the first four places in the queue. In detail, they've got four individual damage skills and an AOE skill.
  1. Decrease the HP of the first enemy in the queue by d_A, with a cost of m_A MP.
  2. Decrease the HP of the second enemy in the queue by d_B, with a cost of m_B MP.
  3. Decrease the HP of the third enemy in the queue by d_C, with a cost of m_C MP.
  4. Decrease the HP of the fourth enemy in the queue by d_D, with a cost of m_D MP.
  5. Decrease the HP of the first four enemies in the queue by , with a cost of m_E MP.



All kinds of skills can be used an infinite number of times. However, Kuma can't use two skills at the same time. Now, Kuma is wondering how much MP at least is needed to defeat all the enemies.

输入描述:

The first line contains ten integers n,d_A,d_B,d_C,d_D,m_A,m_B,m_C,m_D,m_E .

The second line contains  integers , representing the health point of each enemy respectively.

输出描述:

Output a single integer on a line, representing the answer.
示例1

输入

复制
3 5000 3000 10000 15000 14 12 20 28 80
4000 6400 4000

输出

复制
54