Java Binary Search
\nclass Solution {\n    int MOD = 1000000007;\n    public int sumOfFlooredPairs(int[] nums) {\n        Arrays.sort(nums);\n        int n=nums.length,max = nums[
```\nclass Solution {\n    int MOD = 1000000007;\n    public int sumOfFlooredPairs(int[] nums) {\n        Arrays.sort(nums);\n        int n=nums.length,max = nums[n-1];\n        long res=0;\n        \n        int count=1;\n        for(int i=0;i<n;i++){\n            int num = nums[i];\n            if(i<n-1&&nums[i+1]==nums[i]){\n                count++;\n            }else{\n                long sum = count;\n                int index = i+1;\n                for(int k=1;k<=(max/num)+1;k++){\n                    int newIndex = binarySearch(nums,index,n-1,k*num);\n                    //System.out.println(k+" "+newIndex+" "+index);\n                    sum += (newIndex-index)*(k-1);\n                    index = newIndex;\n                }\n                res = (res+(sum%MOD)*count)%MOD;\n                count=1;\n            }\n            \n        }\n        //res+=count*count;\n        return (int)res;\n    }\n    \n    // first large or equal than\n    public int binarySearch(int[] nums, int left, int right, int target){\n        int l = left, r = right;\n        while(l<=r){\n            int mid = l+(r-l)/2;\n            if(nums[mid]>=target){\n                r = mid-1;\n            }else{\n                l = mid+1;\n            }\n        }\n        return l;\n    }\n}\n```
[]