Given a list of integers $a_1,a_2,\dotsc,a_n$, where $0\le a_i\le 100$ for every $i$, where $n\le 100$, find all the distinct possible sums that can be obtained by taking any number of elements from the list and adding them.
Example: for $1,2,3$, the answer is $0,1,2,3,4,5,6$.
My approach was a brute force in which called a recurcive method for an index $i$ and inside that since there are two possibilities (to add a number or to leave it) I once added and again called the recursion and called the recursion again without adding it. This approach is time consuming; can anyone please suggest a faster method because total possible sum is only $10001$ ($0+100\cdot 100$). Thanks.