Python3. Sort + binary search
\nclass Solution:\n    # idea:\n    # first thing is that we can easily cache in this problem:\n    #   if we know result of `sum(nums[i] // nums[k] for k in ra
```\nclass Solution:\n    # idea:\n    # first thing is that we can easily cache in this problem:\n    #   if we know result of `sum(nums[i] // nums[k] for k in range(N))`,\n    #   then we know result for any `j` that `nums[j] = nums[i]`\n    #\n    # second. if we sort "nums", we can use binary search:\n    #   let `nums[i] = P` then we can search for `2 * P` that will be position `j`\n    #   then for all k in `i..j`, `nums[k] // nums[i] = 2`\n    #   then we can search for `3 * P` that will be `t` and for all k in range `j..t`, `nums[k] // nums[i] = 3` and so on\n    \n    def sumOfFlooredPairs(self, nums: List[int]) -> int:\n        nums.sort()\n        res = 0\n        mod = 10 ** 9 + 7\n        cache = {}\n        for i, x in enumerate(nums):\n            if x in cache:\n                res += cache[x]\n            else:\n                current_res = 0\n                j = i                  # initialize with `i` because `nums[i] // nums[j]` when `i < j` in sorted array is always 0\n\t\t\t\t                       # (except cases when `nums[i] = nums[j]`, but duplicates will use cache in this problem)\n                while j < len(nums):\n                    multiplier = nums[j] // x                                   # define multiplier by first element in range\n                    last_position = bisect_left(nums, x * (multiplier + 1), j)  # find all numbers with such multiplier\n                    current_res += (last_position - j) * multiplier             # add result of `sum(nums[k] // nums[i] for k in range(j, last_position))` to `current_res`\n                    j = last_position\n  \n                cache[x] = current_res       # update cache\n                res += current_res\n            res %= mod\n        return res\n                \n```
[]