☕ Java solution
![Screenshot_2.png](https://assets.leetcode.com/users/images/6aebb3b1-d252-4318-9bb1-01a3e703edc6_1736589247.7759259.png)

```java []
class Solution {
    private static final int MOD = (int) 1e9 + 7;

    public int countSubMultisets(List<Integer> nums, int l, int r) {
        int[] numsArray = nums.stream().mapToInt(Integer::intValue).toArray();
        return countSubMultisets(numsArray, l, r);
    }

    private int countSubMultisets(int[] nums, int l, int r) {
        Map<Integer, Integer> freqMap = new HashMap<>();
        for (int num : nums) {
            freqMap.put(num, freqMap.getOrDefault(num, 0) + 1);
        }

        long[] dp = new long[r + 1];
        dp[0] = 1;

        for (Map.Entry<Integer, Integer> entry : freqMap.entrySet()) {
            int num = entry.getKey();
            int count = entry.getValue();

            if (num == 0) {
                dp[0] = (dp[0] + count) % MOD;
                continue;
            }

            long[] prefix = Arrays.copyOf(dp, dp.length);
            for (int i = num; i <= r; i++) {
                prefix[i] = (prefix[i] + prefix[i - num]) % MOD;
            }

            for (int j = r; j >= 1; j--) {
                int k = j - num * (count + 1);
                if (k < 0) {
                    dp[j] = prefix[j];
                } else {
                    dp[j] = (prefix[j] - prefix[k] + MOD) % MOD;
                }
            }
        }

        long result = 0;
        for (int i = l; i <= r; i++) {
            result = (result + dp[i]) % MOD;
        }
        return (int) result;
    }
}
```
['Java']