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

#BS0000250. Thời gian sửa ô tô ít nhất (Minimum Time to Repair Cars)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Thời gian sửa ô tô ít nhất (Minimum Time to Repair Cars)

Minimum Time to Repair Cars

Source: LeetCode

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn mechanics, numbered 1 through nn. There are tt cars waiting to be repaired; all of them must be repaired. Mechanic ii has rank rir_i and needs ric2r_ic^2 minutes to repair cc cars. All mechanics can work independently and simultaneously from time zero. Find the minimum time required.

Input

The first line contains integers n,tn,t, the number of mechanics and required cars.

The second line contains nn integers r1,r2,…,rnr_1,r_2,\ldots,r_n, the ranks of the mechanics.

Output

Print the minimum time as one integer.

Subtasks

  • Subtask 1 (20 points): 1≤n≤1001\le n\le 100; 1≤t≤10001\le t\le 1000; 1≤ri≤1001\le r_i\le 100 for every 1≤i≤n1\le i\le n.
  • Subtask 2 (30 points): 1≤n≤1000001\le n\le 100000; 1≤t≤10000001\le t\le 1000000; 1≤ri≤1001\le r_i\le 100 for every 1≤i≤n1\le i\le n. r1=r2=⋯=rnr_1=r_2=\cdots=r_n.
  • Subtask 3 (50 points): 1≤n≤1000001\le n\le 100000; 1≤t≤10000001\le t\le 1000000; 1≤ri≤1001\le r_i\le 100 for every 1≤i≤n1\le i\le n.

Examples

Input

4 10
4 2 3 1

Output

16

Explanation

In 16 minutes the mechanics can repair 2, 2, 2, and 4 cars, totaling 10. In 15 minutes they can repair only 1, 2, 2, and 3, totaling 8. Hence 16 minutes are necessary.