PivotOJ

Watching Mooloo

시간 제한: 1000ms메모리 제한: 1024MB출처: USACO 2023 February BronzeBOJ 27851

문제

Bessie likes to watch shows on Mooloo. Because Bessie is a busy cow, she has planned a schedule for the next NN (1N1051 \leq N \leq 10^5) days that she will watch Mooloo. Because Mooloo is a paid subscription service, she now needs to decide how to minimize the amount of money she needs to pay.

Mooloo has an interesting subscription system: it costs d+Kd + K (1K1091\le K\le 10^9) moonies to subscribe to Mooloo for dd consecutive days. You can start a subscription at any time, and you can start a new subscription as many times as you desire if your current subscription expires. Given this, figure out the minimum amount of moonies Bessie needs to pay to fulfill her schedule.

입력

The first line contains integers NN and KK.

The second line contains NN integers describing the days Bessie will watch Mooloo: 1d1<d2<<dN10141\le d_1<d_2<\dots<d_N\le 10^{14}.

출력

Note that the large size of integers involved in this problem may require the use of 64-bit integer data types (e.g., a "long long" in C/C++).

예제

예제 1

입력
2 4
7 9
출력
7

예제 2

입력
2 3
1 10
출력
8
코드를 제출하려면 로그인하세요.