Andrei and Alex are playing a game with an array of elements. Andrei can perform at most operations on the array. In each operation, he can decrease any element of the array by 1.
After performing these operations, Andrei must pay Alex dollars, where is the maximum subarray sum of the modified array. The subarray must contain at least one element. Since Andrei wants to pay as little as possible, he chooses his operations optimally to minimize .
An array is a subarray of an array if can be obtained from by deletion of several (possibly, zero) elements from the beginning and several (possibly, zero) elements from the end. In particular, an array is a subarray of itself.
Task
Given , and the array , what is the minimum amount of money Andrei will have to pay Alex?
Input data
The first line contains two integers, and . The second line contains integers .
Output data
You need to write a single line with an integer: the value .
Constraints and clarifications
- .
- .
- for each .
| # | Score | Constraints |
|---|---|---|
| 1 | 0 | Examples |
| 2 | 6 | |
| 3 | 14 | |
| 4 | 6 | for each . |
| 4 | 16 | for each . |
| 5 | 58 | No additional restrictions |
Example 1
stdin
5 2
-1 2 3 -1 4
stdout
6
Explanation
In the first sample case, you can decrease the fifth element two times.
Example 2
stdin
6 7
-2 2 2 3 0 4
stdout
4
Explanation
In the second sample case, you can decrease the fourth element seven times.