100 #ABC216E. [ABC216E] Amusement Park

[ABC216E] Amusement Park

Score : 500500 points

Problem Statement

Takahashi has come to an amusement park. The park has NN attractions. The fun of the ii-th attraction is initially aia_i.

When Takahashi rides the ii-th attraction, the following sequence of events happens.

  • Takahashi's satisfaction increases by the current fun of the ii-th attraction.
  • Then, the fun of the ii-th attraction decreases by 11.

Takahashi's satisfaction is initially 00. He can ride the attractions at most KK times in total in any order. What is the maximum possible value of satisfaction Takahashi can end up with?

Other than riding the attractions, nothing affects Takahashi's satisfaction.

Constraints

  • 1N1051 \leq N \leq 10^5
  • 1K2×1091 \leq K \leq 2 \times 10^9
  • 1Ai2×1091 \leq A_i \leq 2 \times 10^9
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN KK

A1A_1 A2A_2 \dots ANA_N

Output

Print the maximum possible value of satisfaction that Takahashi can end up with.

3 5
100 50 102
502

Takahashi should ride the first attraction twice and the third attraction three times. He will end up with the satisfaction of (100+99)+(102+101+100)=502(100+99)+(102+101+100)=502. There is no way to get the satisfaction of 503503 or more, so the answer is 502502.

2 2021
2 3
9

Takahashi may choose to ride the attractions fewer than KK times in total.