1class Solution {2public int sumOfFlooredPairs(int[] nums) {3Arrays.sort(nums);4int n = nums.length;5long cnt[] = new long[nums[n - 1] + 2];6for (int num : nums) {7cnt[num + 1]++;8}9for (int i = 1; i < cnt.length; i++) {10cnt[i] += cnt[i - 1];11}12long res = 0;13long mod = 1000000007;14long dp[] = new long[cnt.length];15for (int num : nums) {16if (dp[num] != 0) {17res = (res + dp[num]) % mod;18continue;19}20long tot = 0;21for (int j = num; j < cnt.length - 1; j += num) {22tot = (tot + (j / num) * (cnt[Math.min(j + num - 1, nums[n - 1]) + 1] - cnt[j])) % mod;23}24dp[num] = tot;25res = (res + tot) % mod;26}27return (int) res;28}29}