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

. 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

, with a cost of

MP.
2. Decrease the HP of the second enemy in the queue by

, with a cost of

MP.
3. Decrease the HP of the third enemy in the queue by

, with a cost of

MP.
4. Decrease the HP of the fourth enemy in the queue by

, with a cost of

MP.
5. Decrease the HP of the first four enemies in the queue by

, with a cost of

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.