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

#GL0000219. Phân rã bằng ước nguyên tố (Prime Destruction)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Phân rã bằng ước nguyên tố (Prime Destruction)

Phân rã bằng ước nguyên tố (Prime Destruction)

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Given a multiset of nn positive integers aia_i and an integer threshold kk, you may repeatedly choose any element x>1x>1 and a prime divisor pp of xx, remove one occurrence of xx, and insert exactly pp copies of x/px/p. Find the minimum number of operations until all multiset elements are at most kk. Newly inserted elements may also be transformed.

Input

The first line contains n,kn,k; the second contains nn integers aia_i.

Output

Print the minimum number of operations.

Subtasks

  • Subtask 1 (20 points): 1≤k≤n≤1001\le k\le n\le 100; 1≤ai≤n1\le a_i\le n.

  • Subtask 2 (30 points): 1≤k≤n≤50001\le k\le n\le 5000; 1≤ai≤n1\le a_i\le n.

  • Subtask 3 (50 points): 1≤k≤n≤2000001\le k\le n\le 200000; 1≤ai≤n1\le a_i\le n.

Examples

Example 1

Input

6 2
6 6 4 3 2 1

Output

4

Explanation

Change each 6 into three 2s, change 4 into two 2s, and 3 into three 1s, using four operations.

Example 2

Input

1 1
1

Output

0

Explanation

Every element is at most k.

Example 3

Input

8 1
8 6 4 3 2 1 8 6

Output

25

Explanation

For k=1, use the minimum operation cost for each element and sum the independent costs.