Run from i = 000. . 0 to i = 111. . 1 or check all possible subsets of the array
for i in range ( 1 , 1 << n ) : NEW_LINE INDENT mult = 1 NEW_LINE for j in range ( n ) : NEW_LINE INDENT if ( i & ( 1 << j ) ) : NEW_LINE INDENT mult *= a [ j ] NEW_LINE DEDENT DEDENT DEDENT