😆Runtime 160 ms Beats 100.00% of users with Go
Code\n\nfunc sumOfFlooredPairs(arr []int) int {\n    const mod = int(1e9 + 7)\n\t// n := len(arr)\n\tvar ans int64\n\tmax := -1\n\n\tfor _, num := range arr {\n
# Code\n```\nfunc sumOfFlooredPairs(arr []int) int {\n    const mod = int(1e9 + 7)\n\t// n := len(arr)\n\tvar ans int64\n\tmax := -1\n\n\tfor _, num := range arr {\n\t\tif num > max {\n\t\t\tmax = num\n\t\t}\n\t}\n\n\tfreq := make([]int, max+1)\n\tfor _, num := range arr {\n\t\tfreq[num]++\n\t}\n\n\tpre := make([]int, max+1)\n\tfor i := 1; i <= max; i++ {\n\t\tpre[i] = pre[i-1] + freq[i]\n\t}\n\n\tfor i := 1; i <= max; i++ {\n\t\tif freq[i] == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tvar sum int64\n\t\tfor j := 1; i*j <= max; j++ {\n\t\t\tleft := j * i\n\t\t\tright := i * (j + 1) - 1\n\t\t\tif right > max {\n\t\t\t\tright = max\n\t\t\t}\n\t\t\tcount := pre[right] - pre[left-1]\n\t\t\tsum = (sum + int64(j*count)) % int64(mod) \n\t\t}\n\t\tans = (ans + (int64(freq[i]) * sum) % int64(mod)) % int64(mod) \n\t}\n\treturn int(ans)\n}\n```
['Go']