There are two men A and B. There are n tasks, namely task 1, task 2, ..., task n. You must assign each task to one person to solve it. There are some facts you must know and comply with:
1. You must assign each task to only one person to solve.
2. At any time, one person can solve at most one task.
3. Task i (0 < i < n) can be solved if and only if each task j (0 < j < i) has been solved or is solving.
4. If a task is solving by one person, it cannot be interrupted.
5. The same task maybe cost them different time.
6. One person can go to solve his task when another person can also do at the same time.
You want to do finish all the tasks as soon as possible.
For each test case, output the minimum time when all the tasks have been solved.