Doubt regarding sum it problem

I’m trying to solve the sum it up problem by the code shown below. The concept I have used here is that I made two recursive call one if the number is included and the second one if it is not but the problem that I’m facing here is that due to duplicate numbers in the array I’m getting duplicate answers also. for eg.
Input =
7

10 1 2 7 6 1 5

8

I’m getting
output =
1 1 6

1 2 5

1 7

1 2 5

1 7

2 6

i.e. duplicate values due to duplicate numbers in the array .Please suggest some changes in the code to debug for this.

to remove duplicates i check the previous element as duplicacy will be because of the similar characters.

u can see this