Binary Search is good
 # Intuition  \n\n\n\n\n\n# Complexity\n- Time complexity: O(n * log(n))\n\n\n- Space complexity: O(log(n))\n\n\n# Code\n\nclass Solution {\n    int n, mod = (i
<!-- # Intuition -->\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n<!-- # Approach -->\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: $$O(n * log(n))$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(log(n))$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    int n, mod = (int)(1e9 + 7);\n    long pow2(int n) {\n        if(n == 0)\n            return 1;\n        long half = pow2(n / 2);\n        if(n % 2 == 1)\n            return (2 * half * half) % mod;\n        return (half * half) % mod;\n    }\n    int lower_bound(int[] nums, int target) {\n        int l = 0, r = n - 1, mid;\n        while(l <= r) {\n            mid = l + (r - l) / 2;\n            if(nums[mid] <= target)\n                l = mid + 1;\n            else\n                r = mid - 1;\n        }\n        return r;\n    }\n    public int numSubseq(int[] nums, int target) {\n        Arrays.sort(nums);\n        int subs = 0, j;\n        n = nums.length;\n        for(int i = 0; i < n; i++) {\n            j = lower_bound(nums, target - nums[i]);\n            if(j >= i)\n                subs = (int)(subs + pow2(j - i)) % mod;\n        }\n        return subs;\n    }\n}\n```
['Array', 'Binary Search', 'Sorting', 'Java']