```
class Solution(object):
def combinationSum4(self, nums, target):
nums=sorted(nums)
i=0
dp=[]
while(i<=target):
dp.append(0)
i+=1
n=i-1
for i in range(len(nums)):
if nums[i]>n:
break
dp[nums[i]]=1
for i in range(len(dp)):
sum=0
for j in range(len(nums)):
if(nums[j]<i):
sum+=dp[i-nums[j]]
else:
break
dp[i]+=sum
return dp[target]
```