Given an integer array nums, you need to calculate the sum of all floored divisions between every pair of elements in the array.
More specifically, for every pair of indices i and j where 0 <= i, j < nums.length, compute floor(nums[i] / nums[j]) and sum all these values together.
The floor function returns the largest integer less than or equal to the division result. For example, floor(7/3) = 2 and floor(5/2) = 2.
Important: Since the result can be extremely large, return the answer modulo 109 + 7.
Example: For array [2, 5, 9], we calculate: floor(2/2) + floor(2/5) + floor(2/9) + floor(5/2) + floor(5/5) + floor(5/9) + floor(9/2) + floor(9/5) + floor(9/9) = 1 + 0 + 0 + 2 + 1 + 0 + 4 + 1 + 1 = 10
Input & Output
Constraints
- 1 ≤ nums.length ≤ 105
- 1 ≤ nums[i] ≤ 105
- Return result modulo 109 + 7