cswork / OAOpen practice workspace

AmazonOA #215

TikTok Video Relevance Adjustment

Estimated MediumJudge-ready

Topics (AI-labelled)Binary Search

Each operation chooses a positive rating and subtracts a fixed positive integer x from it. All ratings must be ≤0 after at most M operations; find the minimum x. The original example mixed in the process for a different array; for the given [4,3,2,7] with M=5, the correct answer is 4.

Input

The first line contains n M; the second line contains the ratings. 1≤n≤100000, 1≤rating≤10^9, n≤M≤10^9.

Output

Output a single integer, the answer.

Example 1

Input:

4 5
4 3 2 7

Output:

4

Example 2

Input:

3 6
1 2 3

Output:

1

Example 3

Input:

2 2
10 10

Output:

10

Example notes

The answers are 4, 1 and 10. In the first example x=3 needs 2+1+1+3=7 operations, while x=4 needs 1+1+1+2=5.

Editorial

Loading solution…