Brewing potion 3 - MarisaOJ: Marisa Online Judge

Brewing potion 3

Time limit: 1000 ms
Memory limit: 256 MB
Marisa has $n$ mushrooms, $i^{th}$ mushroom weigh $A_i$. Today she wants to make a potion bottle. She can use an arbitrary numbers of mushrooms in a potion bottle but two mushrooms that differ in weight by more than $k$ cannot be used in the same potion bottle. What is the maximum number of mushrooms that can be used to make **two** potion bottle? (Marisa wants her potion to be as strong as possible). ### Input - The first line contains an integers $n$. - The second line contains $n$ integers $A_i$. ### Output - The maximum number of mushrooms can be used. ### Constraints - $1 \le n \le 10^5$. - $1 \le k,A_i \le 10^9$ ### Example Input: ``` 6 3 1 2 5 7 9 10 ``` Output: ``` 5 ```