#P3984. Accumulated Happiness
Accumulated Happiness
Accumulated Happiness
Jinjin has entered high school and has been rigorously trained by her mother. As a result, she has become exceptionally skilled and dominates every OI competition by always securing an Au. Each time she wins an Au, she becomes happy for \(T\) days, including the day of the award. Importantly, if she wins another Au during an ongoing period of happiness, her happiness period resets so that it lasts for \(T\) days starting from that day, rather than extending the current happiness period. Given her schedule for \(n\) upcoming competitions, determine the total number of days Jinjin will be happy. Note that if happiness periods overlap, overlapping days are only counted once.
inputFormat
The first line contains two space-separated integers \(n\) and \(T\), where \(n\) is the number of competitions and \(T\) is the number of days Jinjin remains happy after receiving an Au.
The second line contains \(n\) space-separated integers representing the days on which Jinjin receives an Au. It is guaranteed that these days are given in increasing order.
outputFormat
Output a single integer representing the total number of days Jinjin will be happy.
sample
3 3
1 2 6
7