Shortcut
Pavel has a toy railway. It is very simple. There is a main line consisting of n stations. These stations are numbered from 0 to n − 1 in order along the line. The distance between the stations i and i + 1 is l[i]
centimeters (0 ≤ i < n − 1).
Apart from the main line there may be some secondary lines. Each secondary line is a railway line between a station on the main line and a new station that does not lie on the main line. (These new stations are not numbered.) At most one secondary line can start in each station of the main line. The length of the secondary line starting at station i is d[i]
centimeters. We use d[i]
= 0 to denote that there is no secondary line starting at station i.
Pavel is now planning to build one shortcut: an express line between two different (possibly neighboring) stations of the main line. Express line will have length of exactly c centimeters, regardless of what two stations it will connect.
Each segment of the railway, including the new express line, can be used in both directions. The distance between two stations is the smallest length of a route that goes from one station to the other along the railways. The diameter of the whole railway network is the maximum distance among all pairs of stations. In other words, this is the smallest number t, such that the distance between every pair of stations is at most t.
Pavel wants to build the express line in such a way that the diameter of the resulting network is minimized.
Input
First line contains integers n and c (2 ≤ n ≤ 10^6
, 1 ≤ c ≤ 10^9
).
Second line contains integers l[0]
, ..., l[n − 2]
(1 ≤ l[i]
≤ 10^9
).
Third line contains integers d[0]
, …, d[n − 1]
(0 ≤ d[i]
≤ 10^9
).
Output
Print a single integer denoting the smallest possible diameter.
Example 1
The optimal solution is to build the express line between stations 1 and 3, as shown below.