A test rig logs n turbine RPM readings in run order. You select a subsequence of readings (not necessarily adjacent), keeping run order, that is strictly increasing; additionally, between any two consecutive chosen readings the increase must be at most B (that is, if you chose value u then next value v, you need 0 < v - u <= B). Among all such selections, maximize the total of the chosen readings. A single reading is always a valid selection. Report the maximum achievable total.
Input format
Line 1: two integers n and B.
Line 2: n space-separated integers, the RPM readings in run order.
Output format
A single integer: the maximum sum of a valid selection.
Constraints
- 1 <= n <= 2000
- 1 <= B <= 1000000000
- 1 <= reading <= 1000000
- The answer fits in a signed 64-bit integer.