403660: GYM101234 G Dreamoon and NightMarket

Memory Limit:0 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

G. Dreamoon and NightMarkettime limit per test1 secondmemory limit per test512 mebibytesinputstandard inputoutputstandard output

After moving to Taipei, Dreamoon always goes to dinner at Jinmei Night Market. There are N kinds of food sold at Jinmei Night Market. These foods are numbered from 1 to N. The price of one piece of i-th food is pi.

Every night, Dreamoon will choose a non-empty set of foods and eat one piece of each food in this set. Dreamoon likes new things. So he won't choose the same set in two different nights. Besides this, because Dreamoon is a poor boy, each night, he will choose the cheapest food set that he didn't choose before.

Now, you are given a positive integer K. Can you tell Dreamoon which set of foods he will choose on K-th day? You only have to tell him how much he will spent on this day.

Input

The input consists of two lines. The first line contains an integer N. The second line consists of N integers p1, p2, ..., pN.

  • 2 ≤ N ≤ 2 × 105
  • 1 ≤ K ≤ min(106, 2N - 1)
  • 1 ≤ pi ≤ 108
Output

Output one number indicating how much Dreamoon will spend on food on K-th day.

ExamplesInput
5 30
4 2 1 16 8
Output
30
Input
4 5
1 1 2 2
Output
2

加入题单

上一题 下一题 算法标签: