Dreamoon and NightMarket

아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

After moving to Taipei, Dreamoon always goes to dinner at Jinmei Night Market. There are NN kinds of food sold at Jinmei Night Market. These foods are numbered from 11 to NN. The price of one piece of ii-th food is p_ip\_i.

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 KK. Can you tell Dreamoon which set of foods he will choose on KK-th day? You only have to tell him how much he will spent on this day.

입력

The input consists of two lines. The first line contains an integer NN. The second line consists of NN integers p_1,p_2,,p_Np\_1, p\_2, \ldots, p\_N.

출력

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

제한

  • 2N2×1052 \le N \le 2 \times 10^5
  • 1Kmin(106,2N1)1 \le K \le \min(10^6, 2^N - 1)
  • 1p_i1081 \le p\_i \le 10^8