[CODE ONLY][DEBUG OUTPUT] PYTHON USING Leon's SOLUTION
Using Leon's solutionLINK: https://leetcode.com/problems/maximum-and-minimum-sums-of-at-most-size-k-subsequences/solutions/6300831/python-combinatorics-explaine
# Using Leon's solution
# LINK: https://leetcode.com/problems/maximum-and-minimum-sums-of-at-most-size-k-subsequences/solutions/6300831/python-combinatorics-explained-o-n-log-n


# Code
```python3 []
# Using Leon's solution
# LINK: https://leetcode.com/problems/maximum-and-minimum-sums-of-at-most-size-k-subsequences/solutions/6300831/python-combinatorics-explained-o-n-log-n

class Solution:
    def minMaxSums(self, nums: List[int], k: int) -> int:
        nums.sort()
        grand_total = 0
        possibilities = 1

        max_mod = 1_000_000_007

        n = len(nums)

        for i in range(n):
            current = nums[i]
            mirror = nums[-i - 1]
            # print(f'current nums[{i}]={current}')
            # print(f'mirror nums[{-i - 1}]={mirror}')
            # print(f'\tadded = {current+mirror}')
            # print(f'\t\tadd #{possibilities} of {current+ mirror}')
            grand_total += possibilities * (current + mirror)
            # print(f'\t\t\tnew grandtotal of {grand_total}')
            # print(f'\t\t\t\ttimes to remove comb={comb(i, k - 1)}')
            possibilities = 2 * possibilities - comb(i, k - 1)
            # print(f'\t\t\t\tupdated possibilities to {possibilities}')
            grand_total %= max_mod

        return grand_total

# current nums[0]=1
# mirror nums[-1]=3
# 	added = 4
# 		add #1 of 4
# 			new grandtotal of 4
# 				times to remove comb=0
# 				updated possibilities to 2
# current nums[1]=2
# mirror nums[-2]=2
# 	added = 4
# 		add #2 of 4
# 			new grandtotal of 12
# 				times to remove comb=1
# 				updated possibilities to 3
# current nums[2]=3
# mirror nums[-3]=1
# 	added = 4
# 		add #3 of 4
# 			new grandtotal of 24
# 				times to remove comb=2
# 				updated possibilities to 4
```
['Python3']