JavaScript + TypeScript Solution
```typescript []
function findXSum(nums: number[], k: number, x: number): number[] {
    let res: number[] = []
    let seen: Map<number, number> = new Map<number, number>()

    for(let i: number = 0; i < k; i++){
        seen.set(nums[i], (seen.has(nums[i]) ? seen.get(nums[i]) : 0) + 1);
    }

    for(let i: number = 0; i < nums.length-k+1; i++){
        const sortedHash = [...seen].sort((a, b) => (b[1] == a[1]) ? (b[0] - a[0]) : (b[1] - a[1]));
        let total: number = 0; 

        for(let j: number = 0; j < Math.min(x, seen.size); j++){
            total += sortedHash[j][0] * sortedHash[j][1]
        }

        seen.set(nums[i], seen.get(nums[i])-1);
        if(seen.get(nums[i]) == 0) seen.delete(nums[i])
        seen.set(nums[i+k], (seen.has(nums[i+k]) ? seen.get(nums[i+k]) : 0) + 1);

        res.push(total)
    }

    return res;
};


```
['Hash Table', 'Sliding Window', 'Sorting', 'TypeScript', 'JavaScript']