Simple C++ solution | Prefix Sum
\n#define ll long long\n#define mod 1000000007\nclass Solution {\npublic:\n    int sumOfFlooredPairs(vector<int>& a) {\n        ll n=a.size(),s=0,mx=0;\n       
```\n#define ll long long\n#define mod 1000000007\nclass Solution {\npublic:\n    int sumOfFlooredPairs(vector<int>& a) {\n        ll n=a.size(),s=0,mx=0;\n        for(int i=0;i<n;i++){\n            s+=a[i];mx=max(mx,a[i]*1LL);\n        }\n        vector<int> p(4*mx+1,0);\n        for(int i=0;i<n;i++) p[a[i]]++;\n        for(int i=1;i<=4*mx;i++) p[i]+=p[i-1];\n        ll ans=0;\n        unordered_map<int,int> f;\n        for(int i=0;i<n;i++){\n            if(a[i]==1){\n                ans=(ans+s)%mod;\n                ans%=mod;\n                continue;\n            }\n            if(f.count(a[i])){\n                ans=(ans+f[a[i]])%mod;\n                ans%=mod;\n                continue;\n            }\n            ll cur=0;\n            for(ll j=2;a[i]*(j-1)<=mx;j++){\n                ll cnt=p[j*a[i]-1];\n                cnt-=p[(j-1)*a[i]-1];\n                cur=(cur+(j-1)*cnt)%mod;\n                cur%=mod;\n            }\n            f[a[i]]=cur%mod;\n            ans=(ans+cur)%mod;\n            ans%=mod;\n        }\n        return ans%mod;\n    }\n};\n```
[]