A simple, easy to understand solution using prefix sum
\nclass Solution {\npublic:\n    int sumOfFlooredPairs(vector<int>& nums) {\n        long mod = 1000000007;\n        long sum = 0;\n        \n        int mx = I
```\nclass Solution {\npublic:\n    int sumOfFlooredPairs(vector<int>& nums) {\n        long mod = 1000000007;\n        long sum = 0;\n        \n        int mx = INT_MIN;\n        for(int i=0; i<nums.size(); i++)\n            mx = max(mx, nums[i]);\n\n        vector<int> freq(mx+1);\n        for(int num : nums)\n            freq[num]++;\n        for(int i=1; i<=mx; i++ )\n            freq[i] += freq[i-1];\n        \n        unordered_set<int> uniqueNumbers;\n        for(int num:nums)\n            uniqueNumbers.insert(num);\n        for(int num : uniqueNumbers)\n        {\n            int i=2;\n            long tempSum = 0;\n            while(num*i <=mx)\n            {\n                int sameFloor = freq[num*i-1]-freq[num*(i-1)-1];\n                long sameFloorSum = (sameFloor * (i-1)) % mod;\n                tempSum = (tempSum + sameFloorSum) % mod;\n                i++;\n            }\n            int sameFloor = freq[mx]-freq[num*(i-1)-1];\n            long sameFloorSum = (sameFloor * (i-1)) % mod;\n            tempSum = (tempSum + sameFloorSum) % mod;\n            sum = (sum + (tempSum * (freq[num] - freq[num-1]))%mod)%mod;\n        }\n        return (int)sum;\n\n    }\n};\n```
[]