题目描述
Problem Description
Ringo is playing with cubes where each cube has a side length of 1. He draws N squares with side length 1 on the ground and stacks \( A_i \) cubes on the \( i \)-th square from the left.
Ringo decides to paint the surfaces of the cubes. He will not paint the faces that are in contact with another cube or the ground. However, he is worried that he might not have enough paint. Therefore, he decides to remove \( K \) cubes before painting. It is important that there is at least one cube left on each square.
Ringo wants to minimize the amount of paint needed. Find the minimum area that needs to be painted.
Input Format
The input is given from the standard input in the following format:
\( N \) \( K \) \( A_1 \) \( A_2 \) ... \( A_N \)
- The first line contains two integers \( N\ (1 \leq N \leq 10^5) \) and \( K\ (1 \leq K \leq 10^{14}) \), separated by a space. These represent the number of squares drawn on the ground and the number of cubes to be removed, respectively.
- The second line contains \( N \) integers separated by spaces, representing the number of cubes to be stacked on each square. The \( i \)-th integer \( A_i\ (1 \leq A_i \leq 10^9) \) represents the number of cubes stacked on the \( i \)-th square from the left. It is guaranteed that it is possible to remove \( K \) cubes while leaving at least one cube on each square, i.e., \( \Sigma A_i \geq N + K \).
Output Format
Output the minimum area that needs to be painted in one line. Ensure a newline at the end of the output.
Sample Input and Output
Sample Input #1
7 6
2 3 2 1 2 3 4
Sample Output #1
35
Sample Input #2
10 919924177
114777581 900857217 199708389 41623648 586160911 824291566 209849198 803644124 355106148 180322764
Sample Output #2
9307626516
Notes/Hints
Sample Explanation 1
The figure below shows the initial state of the stacked cubes as seen from the front.

By removing 6 cubes as shown in the figure below, the area to be painted becomes 35.

输入格式
见题面 Input 部分
输出格式
见题面 Output 部分