Account
GitHubFeedback
Drafts and results saved on this device
Submit on CSES.fi
CSES Problemset/Sorting and Searching

Reading Books

#1631
Ask AI

Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.

Open Claude Desktop

Time limit:1.00 s
Memory limit:512 MB
Unsolved
Download Tests (.zip)

There are nn 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 nn: the number of books.

The second line has nn integers t1,t2,…,tnt_1,t_2,\dots,t_n: the time required to read each book.

Output

Print one integer: the minimum total time.

Constraints
  • 1≤n≤2⋅1051 \le n \le 2 \cdot 10^5
  • 1≤ti≤1091 \le t_i \le 10^9
Sample Test Cases (1)
Example 1ID: sample-1
Input
3
2 8 3
Expected Output
16
Tools
1
2
3
4
5
6
7
8
9
10
11
12
Draft saved locally
|1 line, 0 chars
Test Bench
Download .zip
Input (stdin)
3
2 8 3
Expected Output
16