[Python3] Prefix Sum [O(n log n)] using sets to take care of duplicates
\nclass Solution:\n    def sumOfFlooredPairs(self, nums: List[int]) -> int:\n        \n        maximum = 10**5+1\n        freq = [0]*(maximum)\n        mx = num
```\nclass Solution:\n    def sumOfFlooredPairs(self, nums: List[int]) -> int:\n        \n        maximum = 10**5+1\n        freq = [0]*(maximum)\n        mx = nums[0]\n        for n in nums:\n            freq[n] += 1\n            mx = max(mx, n)\n\n        mod = 10**9 + 7\n        for i in range(1, maximum):\n            freq[i] += freq[i-1]\n\n        res = 0\n\n        done = set()\n        for n in nums:\n            if n in done:\n                continue\n            done.add(n)\n            l, r = n, 2*n-1\n            i = 1\n            sum = 0\n            while(l<=mx):\n                sum = (sum + i*(freq[min(r, mx)] - freq[l-1]))%mod\n                i += 1\n                l += n\n                r += n\n            res = (res + sum*(freq[n]-freq[n-1]))%mod\n        return res\n```
[]