Rust Solution
\nuse std::collections::*;\n\ntype Target = usize;\ntype UseValue = usize;\nfn upper_bound(arr: &Vec<Target>, x: &UseValue) -> usize {\n  let mut low = 0;\n  le
```\nuse std::collections::*;\n\ntype Target = usize;\ntype UseValue = usize;\nfn upper_bound(arr: &Vec<Target>, x: &UseValue) -> usize {\n  let mut low = 0;\n  let mut high = arr.len();\n  while low != high {\n    let mid = (low + high) / 2;\n    match arr[mid].cmp(x) {\n      std::cmp::Ordering::Less | std::cmp::Ordering::Equal => {\n        low = mid + 1;\n      }\n      std::cmp::Ordering::Greater => {\n        high = mid;\n      }\n    }\n  }\n  low\n}\n\nfn lower_bound(arr: &Vec<Target>, x: &UseValue) -> usize {\n  let mut low = 0;\n  let mut high = arr.len();\n  while low != high {\n    let mid = (low + high) / 2;\n    match arr[mid].cmp(x) {\n      std::cmp::Ordering::Less => {\n        low = mid + 1;\n      }\n      std::cmp::Ordering::Equal | std::cmp::Ordering::Greater => {\n        high = mid;\n      }\n    }\n  }\n  low\n}\n\nconst MOD:usize = 1_000_000_007;\n\nimpl Solution {\n  pub fn sum_of_floored_pairs(nums: Vec<i32>) -> i32 {\n    let mut map = HashMap::new();\n    for &v in &nums {\n      *map.entry(v as usize).or_insert(0) += 1;\n    }\n    \n    let mut nums = nums.into_iter().map(|v| v as usize).collect::<Vec<usize>>();\n    nums.sort();\n    let n = nums.len();\n    let mut result = 0;\n\n    let mut memo: HashMap<usize, usize> = HashMap::new();\n    for i in 0..n {\n      let base = nums[i];\n      if let Some(v) = memo.get(&base) {\n        result += v;\n        result %= MOD;\n        continue\n      }\n\n      let mut li = upper_bound(&nums, &base);\n      let mut tot = 0;\n      while li < n {\n        let a = nums[li] / base;\n        let v = (a+1) * base;\n        let ri = lower_bound(&nums, &v);\n\n        let nv = ((ri - li) * a) % MOD;\n        tot += nv;\n        tot %= MOD;\n\n        li = ri;\n      }\n      result += tot;\n      result %= MOD;\n      memo.insert(base, tot);\n    }\n    \n    for (_, num) in map {\n      result += num * num;\n      result %= MOD;\n    }\n\n    result as i32\n  }\n}\n```
['Rust']