Time Limit: 20000ms
Memory Limit: 65536kb
DescriptionFuch loves simplicity. For example, he prefer squares better than rectangles.
Fuch has made several square pieces of chocolate, and he's going to pack them into a single square box. All the chocolates must not overlap each other, nor be rotated.
Your task is to write a program to find the smallest box.
InputInput contains multiple test cases.
The first line of each test case contains a single integer n, indicating the number of chocolates. (1<=n<=8)
The second line contains n positive integers which are no more than 10000, indicating the sizes of each chocolate.
A test case with n=0 indicates the end of input.
OutputFor each test case, output the minimum size of box in a single line.
Below figure shows one of the optimal solutions of the last test case.
3 1 2 3 5 1 2 2 2 3 0