Java prefix sum
\nclass Solution {\n    public int sumOfFlooredPairs(int[] nums) {\n        int mod = (int) Math.pow(10,9)+7;\n        HashMap<Integer,Integer> map = new HashMa
```\nclass Solution {\n    public int sumOfFlooredPairs(int[] nums) {\n        int mod = (int) Math.pow(10,9)+7;\n        HashMap<Integer,Integer> map = new HashMap<>();\n        int max = Arrays.stream(nums).max().getAsInt();\n        int [] arr = new int[2*max];\n        for(int num : nums){\n            arr[num]++;\n            map.put(num,map.getOrDefault(num,0)+1);\n        }\n        for(int i = 1;i<arr.length;i++){\n            arr[i]+=arr[i-1];\n        }\n        long total = 0;\n        for(int key : map.keySet()){\n            for(int i = key,j=1;i<arr.length;i+=key,j++){\n                if(i+key-1<arr.length){\n                    int countNums = arr[i+key-1]-arr[i-1];\n                    long val = j*countNums;\n                    val%=mod;\n                    val =  (val*map.get(key))%mod;\n                    total+=val;\n                    total%=mod;    \n                }\n            }\n        }\n        return (int) total;\n    }\n}\n```
[]