F. Kozak Vus and the Candies
Cossack Vus loves jumping and has a sweet tooth for candies. One day, he found himself on a number line where candies were placed at certain integer points, with at most one candy per point. Overjoyed, Vus decided to collect as many candies as he could. To achieve this, he can select any integer x > 1 and an initial position s (where s is an integer). He will then visit all points of the form s+kx, where k is a non-negative integer. Whenever Vus reaches a point with a candy, he picks it up (even though he probably shouldn't!). Your task is to help Vus collect the maximum number of candies possible.
Interaction
You need to implement the following function:
integer solve(integer n, integer g, array of integers m)
n — the number of candies;
g — block number;
m — array of candy positions;
This function should return a single integer — the maximum number of candies Vus can collect.
Input Format
The first line contains two integers n and g (1 ⩽ n ⩽ 10^5
; 0 ⩽ g ⩽ 6) — the number of candies and the block number, respectively.
The second line contains n integers a[1]
, a[2]
, ..., a[n]
(1 ⩽ a[i]
⩽ 10^9
) — the positions where the candies are located. It is guaranteed that all ai are distinct.
Output Format
Output a single integer on one line — the maximum number of candies Vus can collect.
Examples
Note
In the first example, Vus can choose x = 2 and collect candies at positions 1, 3, and 7.In the second example, Vus can choose x = 3 and collect candies at positions 1, 4, 7, 10, and 13.
Scoring
(4 points) n ⩽ 2;
a[i]
⩽ 10;(5 points) n ⩽ 3;
a[i]
⩽10^2
;(12 points) n ⩽ 10;
a[i]
⩽10^2
;(20 points) n ⩽
10^3
;a[i]
⩽10^4
;(25 points) n ⩽
10^4
;a[i]
⩽10^6
;(34 points) no additional constraints.