BETA

Submissions : 35 Accuracy :

25.71

Find all distinct subset (or subsequence) sums
     

Given a set of integers, find distinct sum that can be generated from the subsets of the given sets and print them in an increasing order. It is given that sum of array elements is small.

Input:

The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. The first line of each test case contains an integer N denoting the size of array A.

The second line of each test case contains N space separated integers denoting elements of the array A[ ].


Output:

Print all the distinct sum that can be generated from the subsets in increasing order for each testcase in a new line.


Constraints:

1<= T <=100

1<= N <=100

1<= A[ ] <=100


Example:

Input:

1

5

2 3 4 5 6

Output:

0 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

**For More Examples Use Expected Output**


Contributor: Sujnesh Mishra

Set Default Code

					   
Result:
It is recommended to test your code before clicking 'Submit' button!



                   



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.