Mock CCO '18 Contest 4 Problem 1 - Mining for Minerals

View as PDF

Submit solution

Points: 15 (partial)
Time limit: 0.3s
Memory limit: 64M

Problem type

The Zerg army is working on mining more minerals. They have found a mineral patch of length L. They have a single drone who will mine the minerals.

This drone needs to divide this mineral patch into sections of length L1 through LN. The drone can cut a mineral patch of length x into two mineral patches, one with length y and the other with length xy. It will take the drone x seconds to perform one such cut. It is guaranteed that i=1NLi=L. The patches are unordered.

What is the minimum amount of time it will take this single drone to divide the mineral patch into the desired sections?

Constraints

1N20103

1Li50103

Input Specification

The first line will contain a single integer N.

Each of the next N lines will contain a single integer, Li.

Output Specification

Output the number of seconds it will take for the drone to divide the mineral patch accordingly.

Sample Input

Copy
3
8
5
8

Sample Output

Copy
34

Comments

There are no comments at the moment.