#Lutece1314. Hash Perfectly

Hash Perfectly

Migrated from Lutece 1314 Hash Perfectly

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

In computing, a hash table is a data structure used to implement an associative array, a structure that can map keys to values.

A hash table uses a hash function to compute an index into an array of buckets or slots, from which the desired value can be found. A common hash function is index=key % array_sizeindex=key\ \%\ array\_size (%\% is modulo operator), but it may cause some collisions.

For example, if keys are 1,2,6,101,2,6,10, and we choose array_size=4array\_size=4, the indexes will be 1,2,2,21,2,2,2, where some collisions happen.

To solve the collision, we can use the method known as separate chaining with linked lists.

Seeing the example again, when we try to insert 66, because its index 22 is used, we build a linked list in index 22, and there would be 262\rightarrow 6 in index 22. Insert 1010 next, there would be a linked list 26102\rightarrow 6\rightarrow 10 in index 2.

title

To calculate the efficiency of the hash function, we define a value called ASLASL (Average search length):

ASL=1ni=1nciASL=\frac{1}{n}\sum_{i=1}^{n}c_i

cic_i is the number of times to compare when we search the ithi^{th} key.

Using the example above again, c1=1,c2=1,c3=2,c4=3c_1=1,c_2=1,c_3=2,c_4=3, so ASL=14(1+1+2+3)=1.75ASL=\frac{1}{4}(1+1+2+3)=1.75.

It's obvious that ASLASL can minimize when we choose a sufficiently large array_sizearray\_size, but in fact due to the limitation of memory, array_sizearray\_size must be no more than limitlimit, i.e., 1array_sizelimit1\leq array\_size\leq limit.

Now you are given n keys, try to choose a proper array_sizearray\_size to minimize ASLASL. If there are multiple answers, choose the smallest one.

Input

The first line contains two integers nn and limitlimit.

The second line contains nn integers, where ithi^{th} integer indicates the ithi^{th} key.

1n,limit,key21051\leq n, limit, key\leq 2*10^5

Output

Print the smallest array_sizearray\_size which can minimize ASLASL.

Samples

4 4
1 2 6 10
3

Note

In sample,

if array_size=4array\_size=4, the indexes will be 1,2,2,21,2,2,2, so ASL=14(1+1+2+3)=1.75ASL=\frac{1}{4}(1+1+2+3)=1.75;

if array_size=3array\_size=3, the indexes will be 1,2,0,11,2,0,1, so ASL=14(1+1+1+2)=1.25ASL=\frac{1}{4}(1+1+1+2)=1.25;

if array_size=2array\_size=2, the indexes will be 1,0,0,01,0,0,0, so ASL=14(1+1+2+3)=1.75ASL=\frac{1}{4}(1+1+2+3)=1.75;

if array_size=1array\_size=1, the indexes will be 0,0,0,00,0,0,0, so ASL=14(1+2+3+4)=2.50ASL=\frac{1}{4}(1+2+3+4)=2.50;

So the answer is 33.

Resources

The 14th UESTC Programming Contest Final