A beetle finds itself on a thin horizontal branch. "Here I am on a thin horizontal branch," thinks the beetle, "I feel pretty much like on an x-axis!" It surely is a beetle of deep mathematical thought.
There are also drops of dew on that same branch, each holding units of water. Their beetle–based integer coordinates are . It is clear that the day will be hot. Already in one unit of time one unit of water goes away from each drop.
The beetle is thirsty. It is so thirsty that if it reached a drop of dew it would drink it in zero time. In one unit of time the beetle can crawl one unit of length.
But would all this crawling pay off? That's what buzzes the beetle. So you are to write a program which, given coordinates of dew drops, calculates the maximal amount of water the beetle can possibly drink.
Constraints
when
Input Specification
The input is read from standard input. The first line contains two integers and .
The next n lines contain integer coordinates .
Output Specification
The program should write one line to standard output containing a single integer: the maximal amount of water the beetle can possibly drink.
Sample Input
3 15
6
-3
1
Sample Output
25
Sample Explanation
The beetle first goes to , starting at . time unit passes, so when the beetle drinks, it gets units of water.
The beetle then goes to from . more time units pass, so the beetle drinks units of water.
The beetle goes to from . time units pass, so the beetle drinks unit of water.
In total, the beetle drinks units of water, which is the most it can drink.
Comments