QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 128 MB Total points: 100

#6082. Bytecircle

Statistics

Bytecircle consists of $n$ cities, numbered from 0 to $n-1$, arranged in a specific way. Exactly $n-1$ of them lie on a circle—these are the cities numbered $1, 2, \ldots, n-1$ in order. Pairs of adjacent cities on the circle are connected by bidirectional roads. The capital of Bytecircle (city 0) is located at the center of the circle and is connected by roads to all other cities.

We know the travel time for each road in Bytecircle. The authorities of Bytecircle would like to facilitate communication between cities for the residents. To this end, they want to choose the two most distant cities (in terms of travel time between them) and build airports in them.

Input

The first line of input contains a single integer $n$ ($3 \le n \le 500\,000$), representing the number of cities in Bytecircle. The second line contains $n-1$ positive integers representing the travel times between consecutive cities on the circle (i.e., the $i$-th number represents the travel time between city $i$ and the next city in the sequence on the circle). The third line contains $n-1$ positive integers representing the travel times between the capital and the cities on the circle (i.e., the $i$-th number represents the travel time between the capital and city $i$). We assume that the sum of all travel times between adjacent cities on the circle does not exceed $10^{9}$.

Output

The first and only line of output should contain a single integer—the travel time between the most distant pair of cities in Bytecircle.

Examples

Input 1

6
1 4 5 1 6
3 5 1 8 2

Output 1

7

Note

The pair of most distant cities is (2, 4), and the travel time between them is 7. These are the cities where the airports should be built.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.