Best Java Solution || Beats 80%
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n\n    // T.C = N+N/2+N/3+.....\n    //     = O(NlogN)\n\n    // we do the brute force approach which has the T.C O(n^2)\n    \n    public int sumOfFlooredPairs(int[] arr) {\n        int n = arr.length;\n        long ans = 0;\n        long mod = 1000000007;\n\n        int max = Integer.MIN_VALUE;\n\n        for(int i=0; i<n; i++){\n            max = Math.max(arr[i],max);\n        }\n\n        int freq[] = new int[max+1];\n\n        for(int i=0; i<n; i++){\n            freq[arr[i]]++;\n        }\n\n        int pre[] = new int[max+1];\n\n        for(int i=1; i<=max; i++){\n            pre[i] = pre[i-1]+freq[i];\n        }\n\n        for(int i=1; i<=max; i++){\n            \n            if(freq[i]==0) continue;\n\n            long sum = 0;\n            for(int j=1; j*i<=max; j++){\n                int left = j*i;\n                int right = i*(j+1)-1;\n                right = Math.min(right,max);\n                int count = pre[right]-pre[left-1];\n                sum = (sum+(j*count)%mod)%mod;\n            }\n            ans = (ans + (long)(freq[i]*sum)%mod)%mod;\n        }\n        return (int)(ans%mod);\n    }\n}\n```
['Java']