C++ Solution
CodeApproachFound this wonderful explanation on Youtube:
# Code
```cpp []
class Solution {
public:
    int minMaxSums(vector<int>& nums, int k) {

        sort(begin(nums), end(nums));
        int n(size(nums)), mod(1e9+7);
        vector<vector<int>> ncr(n+1, vector<int>(k+1, 0));
        ncr[0][0] = 1;

        // calculating ncr
        for (int i=1; i<=n; i++) {
            ncr[i][0] = 1;
            for (int j=1; j<=k; j++) {
                ncr[i][j] = (ncr[i-1][j-1] + ncr[i-1][j]) % mod;
            }
        }

        int res(0);

        for (int i=0; i<n; i++) {
            for (int j=1; j<=k; j++) {
                // number Of Subsequences of size k In Which Nums[i] is Max
                int a = ncr[i][j-1];
                // number Of Subsequences of size k In Which Nums[i] is Min
                int b = ncr[n-(i+1)][j-1];
                
                res = (res + ((((((long long)a + b) % mod)) * nums[i] * 1ll) % mod)) % mod;
            }
        }

        return res;
        
    }
};
```
# Approach
Found this wonderful explanation on Youtube: [https://www.youtube.com/watch?v=0nPF0QR2Qzg](https://www.youtube.com/watch?v=0nPF0QR2Qzg)  

['C++']