I have a list (vector) of positive integer numbers, including repetitions. For example, $L = [1, 1, 4, 1, 3]$; I want to calculate the number of different sums obtained by using the elements of $L$, according to their multiplicities.
For example, if $L = [10, 30, 100]$, these sums are $$ sum = \{0, 10, 30, 40, 100, 110, 130, 140\} $$ because $$ sum = \{0,10,30,10+30,100,100+10, 100+30, 100+10+40\} $$
The problem is to determine the cardinality of the $sum$ set.
In the last case, $|sum| = 2^3 = 8 $; however, if $L = [1,1,1,1]$, then $$ sum = [0,1,2,3,4] $$ and $|sum| = 5$.
Must I check all possible $2^k$ ways of sum the elements of $L$ (where $k$ is the length of $L$) in order to calculate $|sum|$?