Javascript Combinatorics 1155ms
```javascript []
const ll = BigInt;
function Combinatorics(N, mod) {
    let fact = Array(N), ifact = Array(N), inv = Array(N);
    comb_init();
    return { comb }
    function comb_init() {
        fact[0] = ifact[0] = inv[1] = 1n;
        for (let i = 2; i < N; i++) inv[i] = (mod - mod / ll(i)) * inv[mod % ll(i)] % mod;
        for (let i = 1; i < N; i++) {
            fact[i] = fact[i - 1] * ll(i) % mod;
            ifact[i] = ifact[i - 1] * inv[i] % mod;
        }
    }
    function comb(n, k) {
        if (n < k || k < 0) return 0n;
        return fact[n] * ifact[k] % mod * ifact[n - k] % mod;
    }
}

const mod = 1e9 + 7, bmod = ll(1e9 + 7);
const minMaxSums = (a, k) => {
    let n = a.length, res = 0n, c = new Combinatorics(n + 5, bmod);
    a.sort((x, y) => x - y);
    for (let l = 1; l <= k; l++) {
        for (let i = 0; i < n; i++) {
            res = (res + ll(a[i]) * c.comb(n - i - 1, l - 1)) % bmod;
            res = (res + ll(a[i]) * c.comb(i, l - 1)) % bmod;
        }
    }
    return Number(res);
};
```
['Math', 'Combinatorics', 'JavaScript']