Test case 1 and 2 not passing sum it up

public static ArrayList aa = new ArrayList<>();

public static void main(String[] args) {

	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int[] a = new int[n];
	for (int i = 0; i < n; i++) {
		a[i] = sc.nextInt();
	}
	int x = sc.nextInt();
	Arrays.sort(a);
	solve(a, x, 0, "");
	Collections.sort(aa);
	String pp = "";
	for (String ss : aa) {
		if (pp.equals(ss)) {
			continue;
		}
		System.out.println(ss);
		pp = ss;
	}
}

public static void solve(int[] denom, int amount, int li, String ans) {

	if (amount == 0) {
		aa.add(ans);
		return;
	}
	for (int i = li; i < denom.length; i++) {
		if (amount >= denom[i]) {
			solve(denom, amount - denom[i], i + 1, ans + denom[i] + " ");
		}
	}
}

Consider the testcase:
15
78 7 62 28 73 68 94 88 65 61 59 21 92 4 97
90

in this, ur code do not give the answer in lexiographical order