This can be put into a mathematical question. In general, we test for each number of i in a[i] whether it can be added by the elements in the domain D. If the value of a[i] is greater than possible solutions in domain D, i also belongs to that domain. Here is how we formulate the mathematical problem. Suppose we already have n elements, x1...xn in domain D, we need to solve for b1...bn where b1x1+...bnxn = i. In other words, x1b1+...+xnbn-i=0. From here, if I let matrix A = [x1, ..., xn], Ab-i=0. The NULL Space of A has a rank of n-1. Therefore, if we can find a solution b01, ..., b0n, such that A[b01, b02, ..., b0n]' = i, we have A*(b+b0) = 0. The number of possible solutions is either 0 or n-1. Now the problem becomes whether we can find one solution such that elements in domain D can be added up to i.