eolymp
bolt
Try our new interface for solving problems
Problems

Landscape Improved

Landscape Improved

Louis L Le Roi-Univers has ordered to improve the landscape that is seen from the royal palace. His Majesty prefers to see a high mountain.

The Chief Landscape Manager is going to raise a mountain for Louis. He represents a landscape as a flat picture on a grid of unit squares. Some of the squares are already filled with rock, while others are empty. This greatly simplifies the design. Unit squares are small enough, and the landscape seems to be smooth from the royal palace.

The Chief Landscape Manager has a plan of the landscape - the heights of all rock-filled columns for each unit of width. He is going to add at most n square units of stones atop of the existing landscape to make a mountain with as high peak as possible. Unfortunately, piles of stones are quite unstable. A unit square of stones may be placed only exactly on top of the other filled square of stones or rock, moreover the squares immediately to the bottom-left and to bottom-right of it should be already filled.

prb7572.gif

Your task is to help The Chief Landscape Manager to determine the maximum height of the highest mountain he can build.

Input

The first line contains two integers w - the width of the existing landscape and n - the maximum number of squares of stones to add (1w105, 0n1018).

Each of the following w lines contains a single integer hi (1hi109) - the height of the existing landscape column.

Output

Print the maximum possible landscape height after at most n unit squares of stones are added in a stable way.

Time limit 1 second
Memory limit 128 MiB
Input example #1
8 4
3
4
2
1
3
3
2
4
Output example #1
5
Input example #2
3 100
3
3
3
Output example #2
4
Source 2015 ACM NEERC, Semifinals, December 6, Problem L