Under construction

Still being built. Things may change

Short Sell

Interview

Time limit1sMemory limit512 MB

Summary
Given N daily prices and a daily interest K per 100 borrowed coins, pick a borrow day and a repay day to maximize profit.
Level

Medium4 of 10

Topics
Array, Prefix sum, Greedy, Math
Solved
No attempts yet

Problem

Simone is learning to trade crypto currencies. Right now, she is looking into a new currency called CryptoKattis. A CryptoKattis can be used to improve your Kattis ranklist score without having to solve problems.

Simone, unlike most competitive programmers, is very perceptive of competition trends. She has lately noticed many coders talking about a new online judge called Doggo, and suspects that using the Kattis judge will soon fall out of fashion. This, of course, will cause the CryptoKattis to rapidly fall in value once demand fades.

To take advantage of this, Simone has performed very careful market research. This has allowed her to estimate the price of a CryptoKattis in dollars during the next NN days. She intends to use this data to perform a short sell. This means she will at some day borrow 100100 CryptoKattis from a bank, immediately selling the currency. At some other day, she must purchase the same amount of CryptoKattis to repay her loan. For every day between (and including) these two days, she must pay KK dollars in interest. What is the maximum profit Simone can make by carefully choosing when to borrow and repay the 100100 CryptoKattis?

Input

The first line of the input contains two integers 1≤N≤100 0001 \le N \le 100\,000 and 1≤K≤1001 \le K \le 100. NN is the number of days you know the CryptoKattis price of, and KK is the cost in dollars of borrowing CryptoKattis per day.

The next line contains NN integers separated by spaces. These are the CryptoKattis prices during the NN days. Each CryptoKattis price is between 11 and 100 000100\,000 dollars.

Output

Output a single decimal number; the maximum profit you can make performing a short sell. If you cannot make a profit no matter what short sell you make, output 00.

Examples2

  1. Example 1

    Input
    5 10
    1000 980 960 940 10
    
    Expected output
    98950
    
  2. Example 2

    Input
    5 100
    100 100 100 103 100
    
    Expected output
    100