JDCC '16 Contest 5 P5 - Victory Towers

View as PDF

Submit solution

Points: 12
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type

After your successful efforts in timing the alien invasion, Flatland has emerged victorious! N of the alien ships have been salvaged and the Flatlanders want to use them to build not one, not two, but three tall statues commemorating this independence day!

Each of the alien ships has it's own length. The Flatlanders line these ships up on end to form three stacks. In order to create a balanced visual piece, they would like to minimize the length of the longest statue. Can you help them determine the minimum height of the longest statue?

Input

Each test case begins with an integer N (1 \le N \le 50). The next line contains N integers H_i (1 \le H_i \le 50), representing the lengths of the ships.

Output

For each test case, output one integer : the minimum length of the longest statue.

Sample Input

4
1 2 3 2

Sample Output

3

Sample Input

6
3 4 5 4 9 8

Sample Output

12

Comments


  • 0
    Ninjaclasher  commented on Dec. 7, 2018, 6:47 p.m.

    New test data has been added to stop hard-code solutions from passing.