5 1 5 3 2 7
28 If Takahashi defeats the 1st, 2nd, 3rd, and 5th monsters, and lets the 4th monster go, he gains experience points as follows: * Defeats a monster with strength $A_1=1$. He gains $1$ experience point. * Defeats a monster with strength $A_2=5$. He gains $5$ experience points. As it is the 2nd defeated monster, he gains an additional $5$ points. * Defeats a monster with strength $A_3=3$. He gains $3$ experience points. * Lets the 4th monster go. Takahashi gains no experience points. * Defeats a monster with strength $A_5=7$. He gains $7$ experience points. As it is the 4th defeated monster, he gains an additional $7$ points. Therefore, in this case, he gains $1+(5+5)+3+0+(7+7)=28$ experience points. Note that even if he encounters a monster, if he lets it go, it does not count as defeated. He can gain at most $28$ experience points no matter how he acts, so print $28$. As a side note, if he defeats all monsters in this case, he would gain $1+(5+5)+3+(2+2)+7=25$ experience points.
2 1000000000 1000000000
3000000000 Beware that the answer may not fit in a $32$\-bit integer.
{
"problem": {
"name": "Bonus EXP",
"description": {
"content": "Takahashi will encounter $N$ monsters in order. The $i$\\-th monster $(1\\leq i\\leq N)$ has a strength of $A_i$. For each monster, he can choose to either let it go or defeat it. Each action awards hi",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "abc369_d"
},
"statements": [
{
"statement_type": "Markdown",
"content": "Takahashi will encounter $N$ monsters in order. The $i$\\-th monster $(1\\leq i\\leq N)$ has a strength of $A_i$.\nFor each monster, he can choose to either let it go or defeat it. \nEach action awards hi...",
"is_translate": false,
"language": "English"
}
]
}