You are given an integer array counts and an integer k.
Perform the following step exactly k times:
Choose an index i whose value counts[i] is the largest in the array (any index if several tie).
Add counts[i] to a running total.
Decrease counts[i] by 1.
Return the running total after all k steps.
It is guaranteed that the sum of counts is strictly greater than k, so a positive value is always available to pick. The total does not depend on how ties are broken.