#P9123. Mooloo Subscription

    ID: 22282 Type: Default 1000ms 256MiB

Mooloo Subscription

Mooloo Subscription

Bessie likes to watch shows on Mooloo. As a busy cow, she has planned a schedule for the next \(N\) days (\(1 \leq N \leq 10^5\)) during which she will watch Mooloo. Mooloo has an interesting subscription system: it costs \(d+K\) moonies to subscribe for \(d\) consecutive days (\(1 \leq K \leq 10^9\)). You can start a subscription at any time and purchase new subscriptions once the current one expires. Given Bessie's schedule, determine the minimum total cost (in moonies) required to cover all the scheduled watch days.

The input consists of two lines. The first line contains two integers \(N\) and \(K\). The second line contains \(N\) space-separated integers representing the days (in strictly increasing order) on which Bessie will watch Mooloo.

inputFormat

The first line contains two integers \(N\) and \(K\) (\(1 \leq N \leq 10^5\), \(1 \leq K \leq 10^9\)). The second line contains \(N\) space-separated integers representing the days (in strictly increasing order) on which Bessie will watch Mooloo.

outputFormat

Output a single integer: the minimum total cost (in moonies) required to cover all scheduled watch days.

sample

3 3
1 3 10
10