cho.sh
Notes
Loading...

Dividing Points

Time limit

2s

Memory limit

128 MB

Problem

There are N points inside a circle, and each point is given by its angle from the center of the circle. The circle must be divided into K sectors, each with central angle 360/K degrees. Depending on the chosen starting angle, the number of points contained in each sector can change.

Given the angles of all points, find the minimum possible difference between the largest number of points in any sector and the smallest number of points in any sector.

No point may lie on the boundary of a sector.

Input

The first line contains two integers N (3 ≤ N ≤ 10,000) and K (3 ≤ K ≤ 1,000). Each of the next N lines contains one real number, the angle of a point. Every angle is at least 0 and less than 360. To avoid answers depending on floating-point roundoff, no pair of points has an angular difference extremely close to an integer multiple of 360/K.

Output

Print the minimum possible difference between the maximum and minimum numbers of points contained in a sector.