#P10837. 『FLA - I』云音泛
『FLA - I』云音泛
Description
In his dream, Qiu planted roses. He remembered that the -th rose was planted at the moment .
A rose comes out as soon as it is planted. However, each rose will bloom for exactly moments (the rose planted at the moment will bloom from the moment to the moment ). After 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 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 and — the number of roses and the blooming time of each rose.
The second line of input contains integers — the planting moment of each rose.
Output Format
Output a single line containing an integer denoting the answer.
5 4
11 9 1 3 12
14
13 7
6 42 58 41 20 60 2 61 45 28 45 28 12
38
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.

If we modify the planting moment of the rose with red mark to (i.e. we modify to , as the figure below), the number of golden moments becomes . It can be proven that there is no other scheme that makes the answer greater than , therefore we should output .

「Constraints」
| Test Id | |||
|---|---|---|---|
Each test is worth points.
For all tests, it is guaranteed that , .
京公网安备 11011102002149号