C++ || O(n*(log(n)
Approach\n1. Sort given array.\n2. For each element from 1st onward find target-element index and put all element combination of total element in that range - 1
# Approach\n1. Sort given array.\n2. For each element from 1st onward find target-element index and put all element combination of total element in that range - 1\n3. For finding all combination we used power of 2 with modulous of 1000000007 and add it in answer. \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(n)$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int modPow(long long base, int exp) {\n        if (exp == 0) return 1;\n        else if (exp == 1) return base;\n        else if (exp%2 == 0) return modPow((base*base)%1000000007,exp/2);\n        else return base*modPow(base,exp-1)%1000000007; \n    }\n    int numSubseq(vector<int>& nums, int target) {\n        int n=nums.size(),i=0;\n        sort(nums.begin(),nums.end());\n        long long ans=0; int x=upper_bound(nums.begin(),nums.end(),target-nums[i])-nums.begin()-1;\n        while(x>=i){\n            int y=modPow(2,x-i);\n            ans=(ans+y)%1000000007;\n            i++;\n            while(nums[x]+nums[i]>target) x--;\n        }\n        return ans;\n    }\n};\n```
['Array', 'Two Pointers', 'Binary Search', 'Sorting', 'C++']