Prefix sum only , and some minor optimizations to get it in O(nlogn)
\nclass Solution {\npublic:\n    int maxn=1e5+1;\n    int sumOfFlooredPairs(vector<int>& nums) {\n        // return 0; \n        vector<long long> v(2*maxn+1);\
```\nclass Solution {\npublic:\n    int maxn=1e5+1;\n    int sumOfFlooredPairs(vector<int>& nums) {\n        // return 0; \n        vector<long long> v(2*maxn+1);\n        long long sum=0, mod=(1e9+7);\n        int mxm=0; \n        int n=nums.size();\n        for(int x: nums) ++v[x], mxm= max(mxm, x);\n        for(int i=1;i<=2*maxn; i++) v[i]+=v[i-1];\n        set<int> set1(nums.begin(), nums.end());\n        for(int x: set1){\n            int l=x, r=x*2 -1;\n            long long res=1; \n            long long sum1=0; \n            while( l<=mxm ){\n                sum1 = ( sum1 + res*(v[r]- v[l-1])  )% mod;\n                l+= x, r+= x; \n                res++ ; \n            }\n            sum1= (sum1 * (v[x]-v[x-1]))%mod;\n            sum = (sum + sum1) %mod; \n        }\n        return sum ; \n    }\n};\n```\n
[]