{"problem":{"name":"Amusement Park","description":{"content":"Takahashi has come to an amusement park.   The park has $N$ attractions. The _fun_ of the $i$\\-th attraction is initially $a_i$. When Takahashi rides the $i$\\-th attraction, the following sequence of ","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc216_e"},"statements":[{"statement_type":"Markdown","content":"Takahashi has come to an amusement park.  \nThe park has $N$ attractions. The _fun_ of the $i$\\-th attraction is initially $a_i$.\nWhen Takahashi rides the $i$\\-th attraction, the following sequence of events happens.\n\n*   Takahashi's _satisfaction_ increases by the current fun of the $i$\\-th attraction.\n*   Then, the fun of the $i$\\-th attraction decreases by $1$.\n\nTakahashi's satisfaction is initially $0$. He can ride the attractions at most $K$ times in total in any order.  \nWhat is the maximum possible value of satisfaction Takahashi can end up with?\nOther than riding the attractions, nothing affects Takahashi's satisfaction.\n\n## Constraints\n\n*   $1 \\leq N \\leq 10^5$\n*   $1 \\leq K \\leq 2 \\times 10^9$\n*   $1 \\leq A_i \\leq 2 \\times 10^9$\n*   All values in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$ $K$\n$A_1$ $A_2$ $\\dots$ $A_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc216_e","tags":[],"sample_group":[["3 5\n100 50 102","502\n\nTakahashi should ride the first attraction twice and the third attraction three times.  \nHe will end up with the satisfaction of $(100+99)+(102+101+100)=502$.  \nThere is no way to get the satisfaction of $503$ or more, so the answer is $502$."],["2 2021\n2 3","9\n\nTakahashi may choose to ride the attractions fewer than $K$ times in total."]],"created_at":"2026-03-03 11:01:14"}}