Prefix array sum of frequencies
\nclass Solution {\n    long long mod = 1e9 + 7;\npublic:\n    int sumOfFlooredPairs(vector<int>& nums) {\n        vector<long long> freq(1e5 + 1, 0);\n        
```\nclass Solution {\n    long long mod = 1e9 + 7;\npublic:\n    int sumOfFlooredPairs(vector<int>& nums) {\n        vector<long long> freq(1e5 + 1, 0);\n        long long sum = 0;\n        int max_number = 1;\n        for (int &n: nums) {\n            freq[n] += 1;\n            max_number = max(max_number, n);\n        }\n        \n        vector<long long> freqSum(1e5 + 1, 0);\n        for (int i = 1;i <= max_number; i++) \n        {\n            freqSum[i] = freqSum[i - 1] + freq[i];\n        }\n        \n        \n        for (int i = 1;i <= max_number;i = i + 1)\n        {\n            if (freq[i] == 0)\n                continue;\n            int j = i;\n            for (;j <= max_number;j = j + i) \n            {\n                long long div = j/i;\n                long long total_cases = freqSum[j - 1] - freqSum[j - i];\n                long long value = ((freq[i] * total_cases * (div - 1))%mod + (freq[i] * freq[j] * div)%mod)%mod;\n                sum = (sum + value)%mod;\n            }\n            \n            if (max_number%i) {\n                long long div = max_number/i;\n                long long total_cases = freqSum[max_number] - freqSum[j - i];\n                sum = (sum + (freq[i] * total_cases * div)%mod)%mod;\n            }\n            cout << endl;\n        }\n        \n        return sum;\n    }\n};\n```\n\nPlease let me know in comments if something is not clear in my code, Happy to share
[]