Hide

Problem F
Fitting Cans

/problems/fittingcans/file/statement/en/img-0001.jpg
A Can Display.

ScrollBar sells a wide range of exotic beers, which all come in cans of an equally wide range of heights. Luckily, all beer cans have the same width; exactly 66 millimeters. All of the beer cans must be on display, so the customers can choose the right beer. The display case will be a nicely decorated wooden rectangle, to be hung behind the bar. Unfortunately, wall space is slightly scarce, so the area taken up by the display case must be as small as possible. Putting all the cans in a long row might not be a good idea, since case must be at least as tall as the tallest beer. Cans can be stacked on top of each other, but not more than two cans high, as this would confuse the customers.

Input

The first line is a single integer $1\leq n\leq 100$, the number of beer cans to display. The second line is $n$ integers $10\leq h_ i\leq 1000$, which are the heights of the beer cans in millimeters.

Output

A single integer; the smallest area (in square millimeters) that the display case can have, if the beer cans are arranged optimally.

Illustration of samples 1–5

\includegraphics[width=.8\textwidth ]{img/samples.pdf}
Sample Input 1 Sample Output 1
3
90 50 150
19800
Sample Input 2 Sample Output 2
1
120
7920
Sample Input 3 Sample Output 3
2
120 150
17820
Sample Input 4 Sample Output 4
3
150 150 150
29700
Sample Input 5 Sample Output 5
4
90 30 120 150
27720
Sample Input 6 Sample Output 6
10
28 59 50 68 95 77 39 17 6 86
35970

Please log in to submit a solution to this problem

Log in