nums and create a frequency array freq of size max_val + 1 to store the count of each number in nums.prefix_sum.total_sum to 0 to store the final result.num in nums.num, iterate over its multiples m up to max_val.m, calculate the range [m * num, (m + 1) * num - 1] and use prefix_sum to find the count of elements in this range.m and add it to total_sum, applying the modulo operation.total_sum by the frequency of num and add it to the final result, again applying the modulo operation.10^9 + 7.