Under construction

Still being built. Things may change

Memories of Passport Stamps

Time limit1sMemory limit2048 MB

Summary
Find the smallest s so that k officers, each stamping between 0 and s pages, can produce exactly the n stamped sections in the passport.
Level

Medium6 of 10

Topics
Binary search, Greedy, Array
Solved
No attempts yet

Problem

You just got a new passport with many blank pages for immigration officers to stamp. Because it has so many pages, the officers are too lazy to use them efficiently, so you may need a new passport sooner than you expect. You planned kk trips. At each passport control, the officer finds some contiguous pages with no stamps and stamps all of them. Which contiguous pages get stamped is not fixed, since the officers are lazy. Now there are not enough contiguous blank pages for your next trip, so you are applying for a new passport. Before that, you leaf through the passport and recall your trips. What you disliked most was waiting for the officers to stamp it. Looking back, you took kk trips, and the stamped pages form nn contiguous sections. Find the minimum value ss such that each officer can stamp between 00 and ss pages (inclusive), so that the stamped sections are exactly the ones in your passport now. Different officers may stamp different numbers of pages, and an officer may stamp zero pages.

Input

The first line contains two integers nn (1≤n≤1051 \le n \le 10^5) and kk (n≤k≤1018n \le k \le 10^{18}), where nn is the number of contiguous stamped sections and kk is the number of trips. Each of the next nn lines contains one integer pp (1≤p≤10181 \le p \le 10^{18}), the number of contiguous stamped pages in one section. The passport has at most 101810^{18} stamped pages in total.

Output

Output a single integer, the minimum value ss such that each officer can stamp between 00 and ss pages, inclusive, so that the stamped sections are exactly the ones in your passport now.

Examples1

  1. Example 1

    Input
    3 5
    9
    12
    5
    
    Expected output
    6