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

#GD0000095. Cắt bánh mì (Bread)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Cắt bánh mì (Bread)

Bread

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

A loaf has length LL. Each of nn recipients needs one piece of length aia_i. Cutting a piece of integer length xx into two positive pieces costs xx. Unused bread is allowed. Find the minimum cutting cost.

Input

The first line contains n,Ln,L; the next contains nn requested lengths aia_i.

Output

Print the minimum total cutting cost.

Subtasks

  • Subtask 1 (20 points): 2≤n≤242\le n\le 24; 1≤ai≤1091\le a_i\le10^9; ∑iai≤L≤1015\sum_i a_i\le L\le10^{15}.
  • Subtask 2 (30 points): 2≤n≤15002\le n\le 1500; 1≤ai≤1091\le a_i\le10^9; ∑iai≤L≤1015\sum_i a_i\le L\le10^{15}.
  • Subtask 3 (50 points): 2≤n≤2000002\le n\le 200000; 1≤ai≤1091\le a_i\le10^9; ∑iai≤L≤1015\sum_i a_i\le L\le10^{15}.

Examples

Input

5 7
1 2 1 2 1

Output

16

Explanation

Cut 77 into 33 and 44 (cost 77), 33 into 11 and 22 (cost 33), 44 into 22 and 22 (cost 44), and one 22 into two 11s (cost 22). Total 1616.