Sorting + Dp (Little tricky)
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
#define ll long long int
#define pb push_back
    ll dp[100001][101];
    ll n, M = 1e9 + 7;
    // forward dp
    ll rec(ll level, ll left) {
        // base case
        if (level == n) {
            return 1;
        }
        // cache check
        if (dp[level][left] != -1) {
            return dp[level][left];
        }
        // transitions
        ll ans = rec(level + 1, left);
        if (left > 0) {
            ans = (ans + rec(level + 1, left - 1)) % M;
        }
        // save and return
        return dp[level][left] = ans;
    }
    int minMaxSums(vector<int>& nums, int k) {
        sort(nums.begin(), nums.end());
        n = nums.size();
        vector<ll> a;
        for (ll i = 0; i < n; i++) {
            for (ll j = 0; j < k; j++) {
                dp[i][j] = -1;
            }
        }
        ll ans = 0;
        for (ll i = 0; i < n; i++) {
            ll x = rec(i + 1, k - 1);
            a.pb(x);
        }
        for (ll i = 0; i < n; i++) {
            ll x = (a[i] + a[n - 1 - i]) % M;
            ll y = (nums[i] * x) % M;
            ans = (ans + y) % M;
        }
        return ans;
    }
};
```
['C++']