408009: GYM102961 W Reading Books

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

W. Reading Bookstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

There are $$$n$$$ books, and Kotivalo and Justiina are going to read them all. For each book, you know the time it takes to read it.

They both read each book from beginning to end, and they cannot read a book at the same time. What is the minimum total time required?

Input

The first input line has an integer $$$n$$$: the number of books.

The second line has n integers $$$t_1,t_2,\dots,t_n$$$: the time required to read each book.

Constraints:

  • $$$1 \le n \le 2\cdot 10^5$$$
  • $$$1 \le t_i \le 10^9$$$
Output

Print one integer: the minimum total time.

ExampleInput
3
2 8 3
Output
16

加入题单

算法标签: