This page is still under construction.

Parts of this page are still being built. What you see may change.

Byteocircle

Time limit1sMemory limit128 MB

Summary
Find the largest fastest-route travel time between any two cities in a wheel network with a central capital and a rim cycle.
Level

Hard8 of 10

Topics
Shortest path, Graph, Binary search, Sliding window
Solved
No attempts yet

Problem

Byteocircle is a country of nn cities numbered 00 through n−1n-1. Exactly n−1n-1 of them lie on a circle, and walking around it you meet cities 1,2,…,n−11, 2, \ldots, n-1 in that order. Every two neighbouring cities on the circle are joined by a two-way road. The capital, city 00, sits at the centre of the circle and has a road to every other city.

The travel time along each road is known. The government wants to make travelling between cities easier, so it will pick the two cities that are farthest apart and build an airport in each of them. The distance between two cities is the travel time of the fastest route from one to the other.

Input

The first line contains the number of cities nn. (3≤n≤500 0003 \le n \le 500\,000)

The second line contains n−1n-1 positive integers. The ii-th of them is the travel time of the road between city ii and the next city on the circle. The city that follows city n−1n-1 is city 11.

The third line contains n−1n-1 positive integers. The ii-th of them is the travel time of the road between the capital and city ii.

The travel times of all roads add up to at most 10910^9.

Output

Print one integer, the travel time between the two farthest cities.

Hint

In the example the two farthest cities are city 22 and city 44, and the travel time between them is 77. The airports belong in those two cities.

Examples1

  1. Example 1

    Input
    6
    1 4 5 1 6
    3 5 1 8 2
    
    Expected output
    7