Sum it up problem

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner cin = new Scanner(System.in);
int n = cin.nextInt(), arr[] = new int[n];
for(int i = 0;i<arr.length;i++){
arr[i] = cin.nextInt();
}
Arrays.sort(arr);
int t = cin.nextInt();
printCombinations(arr,t,"",-1);
}
public static void printCombinations(int []arr, int t , String ans, int lastIndexVisited){
if(t<=0){
System.out.println(ans);
return;
}
for(int i = lastIndexVisited+1;i<arr.length;i++){
if(t>=arr[i]){
printCombinations(arr,t-arr[i],ans+" "+arr[i], i);
}
}
}
}=======what’s the error in code please make corrections

@AbhishekAhlawat1102 for the case
7
10 1 2 7 6 1 5
8

you have 1 twice so u r getting
1 1 6
1 2 5
1 7
1 2 5
1 7
2 6

but u only have to print unique pairs.correct that