Two computers need to process n tasks - they need to process data from datasets. Each task takes time to complete. Each of the computers needs to process all the n tasks. Yet, whenever one computer works on a dataset, another one is not able to access it. You want to make sure the work is done as fast as possible.

Input

The first line of the input contains a single integer n (2 β€ n β€ ).

The next line contains n space-separated integers (1 β€ β€ ) the time it takes to complete each task.

Output

The program should print the minimal time required to complete all the tasks for both computers.

Examples

Input

Output

4
4 9 1 2

18

Explanation

The first computer processes tasks with durations 1, 2, and 4 (7 in total), while the second one processes the task with duration 9. After finishing it, the second one starts processing the tasks with durations 1, 2, and 4, while the first one starts working on the task with duration 9. Therefore, the total time to complete all the tasks for both computers is 18.