This problem is very hard!
Intuition\n\nThis problem involves finding the sum of all pairs (nums[i], nums[j]) in an array such that for each pair, the result is the quotient of nums[j] / 
## Intuition\n\nThis problem involves finding the sum of all pairs `(nums[i], nums[j])` in an array such that for each pair, the result is the quotient of `nums[j] / nums[i]` floored (i.e., the integer part of the division). The challenge lies in efficiently calculating this sum for all pairs without directly simulating each division, which would be prohibitively slow for large arrays.\n\n## Approach\n\n1. **Precompute Prefix Sums for Counts**: Calculate and store the count of numbers greater than or equal to each number up to the maximum number in `nums`. This allows us to quickly find out how many numbers in `nums` can be divided by a given number `num` with a quotient `q` (where `q > 0`).\n\n2. **Map Counts of Unique Numbers**: Count the occurrences of each unique number in `nums`. This step is crucial for avoiding redundant calculations for repeated numbers.\n\n3. **Iterate Through Unique Numbers**: For each unique number `num`, iterate through its multiples up to the maximum number in `nums`. For each multiple, add to the total count the product of the count of numbers greater than or equal to the current multiple and the count of `num` itself. This effectively calculates the contribution of `num` to the final answer, taking advantage of the precomputed prefix sums for quick lookup.\n\n4. **Modulo Operation**: Since the answer could be very large, take the modulo of the total count with `10^9 + 7` at each step to keep the number within integer limits.\n\n## Complexity\n\n- **Time Complexity**: `O(n + k*log(k))`, where `n` is the size of the input array and `k` is the maximum value in the array. This is because we iterate over the array multiple times (to fill the prefix sums and to count occurrences), and for each unique number, we potentially iterate through its multiples up to `k`.\n\n- **Space Complexity**: `O(k)`, where `k` is the maximum value in the array. The space is mainly used by the array to store counts of numbers greater than or equal to each number up to `k`, and a map to store counts of unique numbers in the input array.\n\n# Code\n```ts\nfunction sumOfFlooredPairs(nums: number[]) {\n    const MAX = Math.max(...nums);\n\n    const countsGreaterOrEqualTo = new Array(MAX + 1).fill(0);\n\n    nums.forEach((num) => (countsGreaterOrEqualTo[num] += 1));\n\n    for (let num = MAX - 1; num >= 0; num -= 1) {\n        countsGreaterOrEqualTo[num] += countsGreaterOrEqualTo[num + 1];\n    }\n\n    const numCounts = nums.reduce((counts, num) => {\n        counts.set(num, (counts.get(num) || 0) + 1);\n        return counts;\n    }, new Map());\n\n    const MOD = 10 ** 9 + 7;\n    let totalCount = 0;\n\n    numCounts.forEach((count, num) => {\n        let current = num;\n\n        while (current <= MAX) {\n            totalCount =\n                (totalCount + countsGreaterOrEqualTo[current] * count) % MOD;\n            current += num;\n        }\n    });\n\n    return totalCount;\n}\n\n```
['TypeScript']