To expand on Kevin's comment (and using an answer since a comment doesn't have enough characters!) : one other obvious-but-relevant constraint that's going to be an issue for large values of $N$ is that the number of possible answers that can be acheived is a function strictly of $n$ and not of the $a_i$ (modulo a few minor issues like repetition of values etc): there are only $C_{n-1}$ 'operation' trees with $n$ leaves, where $C_n$ are the Catalan numbers, approximately $4^n$ plus some polynomial factors; since each of the $(n-1)$ internal nodes can be filled with one of 4 binary operators that adds another factor of $4^{n-1}$ to the total; and of course the $a_n$ can be permuted in $n!$ ways, so the overall bound is something like $n^n\alpha^n$ for $\alpha \approx 16/e \approx 5.9$; concretely, there are a maximum of $C_3 * 4^3 * 4!$ = 5 * 64 * 24 = 7680 possibilities for the $n=4$ case, so if $N$ is larger than this, you're guaranteed to have gaps regardless of the values for $a_i$.