In the Arctic Ocean, there lives a special species of penguins that can fly, but cannot swim. However, these penguins love the water, so they came up with a solution - they'd wrap ropes around their bodies so other penguins can pull them back up! Despite this ingenious invention of rope to allow the penguins to swim, not all of the penguins are the brightest creatures on the planet, and often forget to tie a rope to them before diving underwater. In fact, Bob the penguin was specifically delegated the job of reminding other penguins to wrap a piece of rope around them before leaving.
Unfortunately, penguins sometimes slip into the water, and it is Bob's job to rescue these penguins from the ocean with the rope segments he is given, with the
th segment having a unique integer length of
meters, and thickness 1 centimeter. Bob can tie exactly two pieces of rope together to form a longer piece of rope(assume no length is used for the knot). Then, he can wrap any newly formed or remaining rope segments with the same length together to form a thicker rope to use for the rescue mission.
Since this is a rescue mission, Bob wants the rope used to be as thick as possible given that it is long enough to reach the fallen penguin, who is meters away from Bob. Note that Bob does NOT have to use all the ropes.
Input Specification
The first line of input will contain two space-separated integers and
, representing the number of ropes Bob has and the distance of the fallen penguin from Bob, in meters.
The second line of input will contain space-separated integers, with the
th integer representing
, the length of the
th rope.
Output Specification
Output one integer , the thickness of the thickest rope that can be formed, in centimeters, or -1 if the penguin cannot be reached.
Subtasks
For all test cases,
Subtask 1 [25%]
Subtask 2 [75%]
No additional constraints.
Sample Input 1
5 4
1 5 2 4 6
Sample Output 1
3
Explanation for Sample Input 1
Bob can tie the ropes with length 1 and 5 together to form a rope with length 6, and the ropes with length 2 and 4 to do the same. Then, he can wrap the 3 ropes with length 3 together to form a rope with thickness 3 and length 6, which is long enough to reach the fallen penguin.
Comments