Python Easy to Understand Solution | Sorting | Binary Search
\n\n# Code\n\nclass Solution:\n    def sumOfFlooredPairs(self, nums: List[int]) -> int:\n        nums.sort()\n        res, mod, cache = 0, 1000000007, {}\n     
\n\n# Code\n```\nclass Solution:\n    def sumOfFlooredPairs(self, nums: List[int]) -> int:\n        nums.sort()\n        res, mod, cache = 0, 1000000007, {}\n        for idx, num in enumerate(nums):\n            if num in cache:\n                res += cache[num]\n            else:\n                currentRes, j = 0, idx\n                while j < len(nums):\n                    multiplier = nums[j] // num\n                    lastPosition = bisect_left(nums, num * (multiplier + 1), j)\n                    currentRes += (lastPosition - j) * multiplier\n                    j = lastPosition\n                cache[num] = currentRes\n                res += currentRes\n            res %= mod\n        return res\n```
['Binary Search', 'Sorting', 'Python', 'Python3']