PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GD0000175. Nước chanh cho bữa tiệc (Party Lemonade)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Nước chanh cho bữa tiệc (Party Lemonade)

Party Lemonade

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

A shop sells nn types of lemonade bottles. Type ii has a volume of exactly 2i−12^{i-1} liters and costs cic_i units of money. There is an unlimited supply of every type, and you may buy multiple bottles of the same type.

You need at least LL liters for a party. Buying more than LL liters is allowed if it is cheaper. Find the minimum total cost.

Input

Line 1 contains integers n,Ln,L: the number of bottle types and the minimum volume in liters.

Line 2 contains exactly nn integers c1,c2,…,cnc_1,c_2,\ldots,c_n; cic_i is the price of a bottle of volume 2i−12^{i-1} liters.

Output

Print one integer: the minimum total cost of buying at least LL liters.

Subtasks

  • Subtask 1 (20 points): 1≤n≤61\le n\le6; 1≤L≤641\le L\le64; 1≤ci≤1091\le c_i\le10^9 for every 1≤i≤n1\le i\le n.
  • Subtask 2 (30 points): 1≤n≤151\le n\le15; 1≤L≤1051\le L\le10^5; 1≤ci≤1091\le c_i\le10^9 for every 1≤i≤n1\le i\le n.
  • Subtask 3 (50 points): 1≤n≤301\le n\le30; 1≤L≤1091\le L\le10^9; 1≤ci≤1091\le c_i\le10^9 for every 1≤i≤n1\le i\le n.

Examples

Input

4 12
20 30 70 90

Output

150

Explanation

The bottle sizes are 1,2,4,81,2,4,8 liters with prices 20,30,70,9020,30,70,90. One 88-liter bottle and two 22-liter bottles provide 8+2+2=128+2+2=12 liters for 90+30+30=15090+30+30=150. Two 88-liter bottles cost 180180 and one 88-liter plus one 44-liter costs 160160. No cheaper purchase reaches the required volume, so the output is 150150.