[Python] Suffix sums detailed explanation
\ndef sumOfFlooredPairs(self, nums: List[int]) -> int:\n        maxn = 10**5 + 7\n        MOD = 10**9 + 7\n        f = [0  for i in range(maxn + 1)]    # keep a
```\ndef sumOfFlooredPairs(self, nums: List[int]) -> int:\n        maxn = 10**5 + 7\n        MOD = 10**9 + 7\n        f = [0  for i in range(maxn + 1)]    # keep a count of the frequency of each element in the array\n        sf = [0  for i in range(maxn + 1)]   # suffix array of the frequencies, sf[i] represents frequency of elements greater than equal to i\n        n = len(nums)\n        \n        #create frequency array\n        for i in range(n):\n            f[nums[i]] += 1\n            \n        #create suffix array of frequencies\n        for i in range(maxn-1, 0, -1):\n            sf[i] = sf[i + 1] + f[i]\n            \n        ans = 0\n        """\n        for a element x consider all pairs such that x is the denominator\n        all numbers less than x will result in 0(float division)\n        now for elements greater than x, \n            numbers from x to 2*x - 1 will result in 1\n            numbers from 2*x to 3*x - 1 will result in 2 and so on   \n            \n        so each number from x to 2*x - 1 will add 1 to the answer\n           each number from 2*x to 3*x - 1 will add 2 to the answer \n           each number from 3*x to 4*x - 1 will add 3 to the answer and so on\n           \n        """\n        for i in range(1, maxn + 1):\n            if f[i] == 0:\n                continue\n            res = 1\n            for j in range(i, maxn + 1, i):\n                #number of elements which add res to the answer are sf[j] - sf[j+i]\n                #multiply by f[i] to handle duplicate elements, as there are f[i] number of elements equal to i\n                ans += (sf[j] - sf[min(j + i, maxn - 1)]) * res * f[i]     \n                ans = ans % MOD\n                res += 1\n                \n        return ans % MOD\n```
[]