Random conditional association
There is a similar problem, where you're looking for pairs with a given sum $S$.

For that problem, you initialize an empty set and then iterate once through your numbers. For each number $x$ you do:


Check, if the number $S-x$ is in the set. If it is, you can form the pair $(x,S-x)$.
Add $x$ to the set.


If its allowed to use a number twice, you would only have to switch step (1) and (2). 

To check for ranges instead of exact sums you would have to adapt your data structure. You would exchange the set with a range tree and do the following:


Query your range tree for the range $(low-x,high-x)$ (where low and high are 20 and 27 in your example). This query will return a set $P$ of numbers and you can form a pair  $(x,p) \forall p \in P$.
Add $x$ to the range tree. 


Obviously, this approach only works for pairs. If you want to get all tuples with 4 elements you could first generate all distinct pairs and then try to combine them with the approach I've outlined above. This would result in an $\mathcal O (n^2 \log n)^*$ algorithm (same for tuples with 3 elements, though you would add the pair-sums to the DS and query with the elements from your initial array and not with other pair-sums).

*: This runtime is only correct if the size of tuples in a range is bounded with $\mathcal O(1)$. The worst case without this assumption is of course $\mathcal (N^4)$, when e.g. you have $N$ positive numbers and your allowed range is from $0$ to $\infty$ (result = all possible 4-tuples, without constraints).

PS: I think it's highly likely, that there cannot be a better algorithm, as this problem is an adaptation of 3SUM.