This page is still under construction.

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

Go-Kart

Interview

Time limit1sMemory limit1024 MB

Summary
Find the smallest fuel-tank capacity that lets a kart refuel at given stations and travel at least K kilometers.
Level

Medium5 of 10

Topics
Binary search, Greedy, Sorting
Solved
No attempts yet

Problem

Vytautas got a new go-kart as a Christmas gift and wants to test it on a long, straight karting track.

The kart starts the track with a full fuel tank. It burns one liter of fuel for every kilometer driven and keeps going straight as long as there is fuel in the tank. The tank can be refilled to full at any fuel station.

There are NN fuel stations on the track; the ii-th station stands pip_i kilometers from the start of the track.

Help Vytautas find the smallest fuel-tank capacity that lets him drive at least KK kilometers.

Input

The first line contains two positive integers: the number of fuel stations NN and the distance KK (in kilometers) that Vytautas wants to drive.

The second line contains NN positive integers. The ii-th of them is the distance (in kilometers) of the ii-th station from the start of the track. The station positions are not necessarily sorted.

Output

Print a single integer: the minimum fuel-tank capacity (in liters) that lets Vytautas drive at least KK kilometers.

Constraints

  • 1≤N≤1051 \le N \le 10^5
  • 1≤K,p1,p2,…,pN≤1091 \le K, p_1, p_2, \dots, p_N \le 10^9
  • More than one station may stand at the same kilometer.

Examples1

  1. Example 1

    Input
    5 50
    25 5 28 48 40
    
    Expected output
    20