P10837 『FLA - I』Drifting Clouds' Rhythm

Background

"... How is it going these years?" "... There's no such thing as good or bad. Life is a dream of emptiness, the glorious youth and the hoary head, are nothing but an instant. Only the law of natural repeats, never changing ..."

Description

In his dream, Qiu planted $n$ roses. He remembered that the $i$-th rose was planted at the moment $t_i$. A rose comes out as soon as it is planted. However, each rose will bloom for exactly $m$ moments (the rose planted at the moment $T$ will bloom from the moment $T$ to the moment $T+m-1$). After $m$ moments, the rose turns into unretained dust, fading away in the cold wind. Qiu asks you, if he can change the planting moment of at most one rose (that is, select an $t_i$ and modify it to an arbitrary positive integer), for how many moments at most will there be exactly one rose blooming?

Input Format

The first line of input contains two integers $n$ and $m$ — the number of roses and the blooming time of each rose. The second line of input contains $n$ integers $t_1,t_2,\dots, t_n$ — the planting moment of each rose.

Output Format

Output a single line containing an integer denoting the answer.

Explanation/Hint

**「Sample Explanation #1」** As the figure below, use golden stripes to mark the moments when exactly one rose is blooming, and use black and red stripes to mark the periods when each rose comes out. ![example1](https://cdn.luogu.com.cn/upload/image_hosting/1u42cn1k.png) If we modify the planting moment of the rose with red mark to $17$ (i.e. we modify $t_1$ to $17$, as the figure below), the number of golden moments becomes $14$. It can be proven that there is no other scheme that makes the answer greater than $14$, therefore we should output $14$. ![example2](https://cdn.luogu.com.cn/upload/image_hosting/ig0pgy5w.png) **「Constraints」** | Test Id | $n \leq$ | $m \leq$ | $t_i \leq$ | | :----------: | :------: | :------: | :--------: | | $1 \sim 6$ | $5000$ | $5000$ | $5000$ | | $7 \sim 12$ | $2 \times 10^5$ | $2 \times 10^5$ | $2 \times 10^5$ | | $13 \sim 14$ | $2 \times 10^5$ | $1$ | $10^9$ | | $15 \sim 20$ | $2 \times 10^5$ | $10^9$ | $10^9$ | Each test is worth $5$ points. For all tests, it is guaranteed that $1 \leq n \leq 2 \times 10^5$, $1 \leq m,t_i \leq 10^9$.