beat 100% javascript
js\n/**\n * @param {number[]} nums\n * @return {number}\n */\n// [2,5,9]\n// Runtime: 212 ms, faster than 100.00% of JavaScript online submissions for Sum of Fl
```js\n/**\n * @param {number[]} nums\n * @return {number}\n */\n// [2,5,9]\n// Runtime: 212 ms, faster than 100.00% of JavaScript online submissions for Sum of Floored Pairs.\n// Memory Usage: 51.6 MB, less than 50.00% of JavaScript online submissions for Sum of Floored Pairs.\n// 1 <= nums[i] <= 10^5\nexport default (nums) => {\n  const MODULUS = 1000000007;\n  // const MAX = 100000;\n  let MAX = 0;\n  for (let i = 0; i < nums.length; i++) {\n    MAX = Math.max(MAX, nums[i]);\n  }\n  const counts = new Array(MAX + 1).fill(0);\n\n  for (let num of nums) {\n    // \u8868\u793Acounts[i] \u8868\u793Ai\u6709\u591A\u5C11\u4E2A\u6570\n    ++counts[num];\n  }\n\n  for (let i = 1; i <= MAX; ++i) {\n    // \u5347\u7EA7\u6210\u524D\u7F00\u548C\uFF0C\u8868\u793A\u5C0F\u4E8E\u7B49\u4E8Ei\u7684\u6709\u591A\u5C11\u4E2A\u6570\n    counts[i] += counts[i - 1];\n  }\n\n  let total = 0;\n  // \u5F53floor(x/y) y\u7B49\u4E8Ei\u7684\u65F6\u5019\uFF0C\u6709\u591A\u5C11\u4E2Ax\n  for (let i = 1; i <= MAX; ++i) {\n    // \u5728\u8FD9\u4E2A\u8303\u56F4\u5B58\u5728i\n    if (counts[i] > counts[i - 1]) {\n      let sum = 0;\n      // \u5728floor\uFF08x/y\uFF09\u7B49\u4E8Ej\u7684\u65F6\u5019\uFF0C\u6709\u591A\u5C11\u4E2Ax\n      for (let j = 1; i * j <= MAX; ++j) {\n        // \n        const lower = i * j - 1;\n        const upper = i * (j + 1) - 1;\n        let maxCount = counts[Math.min(upper, MAX)]\n          ? counts[Math.min(upper, MAX)]\n          : 0;\n        // counts[Math.min(upper, MAX)] - counts[lower]\n        sum += (maxCount - counts[lower]) * j;\n      }\n      //\n      total = (total + (sum % MODULUS) * (counts[i] - counts[i - 1])) % MODULUS;\n    }\n  }\n  return total;\n};\n\n```
[]