nums in ascending order.prev to 0 to keep track of the prefix sum of minimum values.sum to 0 to keep track of the total power sum.nums array.
a. For each hero at position i, calculate the power when this hero is the maximum in the group.
b. Update prev to include the current hero in the prefix sum of minimum values.
c. Add the calculated power to sum.sum modulo 10^9 + 7.