TITLE: Quadratic residues and nonresidues of arbitrary patterns
QUESTION [8 upvotes]: Let $p_1, p_2, \dotsc, p_n$ be distinct primes, and let $\epsilon_1, \epsilon_2, \dotsc, \epsilon_n$ be an arbitrary sequence of $1$ and $-1$.
There is an integer $a$ such that $\left( \frac{a}{p_1} \right) = \epsilon_1, \left( \frac{a}{p_2} \right) = \epsilon_2, \dotsc, \left( \frac{a}{p_n} \right) = \epsilon_n$, where $\left( \frac{a}{p_i} \right)$ denotes Legendre's symbol.
What can we say about the number $a$? -- I couldn't find any results for such numbers.
In particular, I am interested in bounds for the smallest possible $|a|$.
Could you recommend any papers or books on the topic?
EDIT
It's better to write "distinct odd primes" for $p_1, p_2, \dotsc, p_n$.
I have checked for several primes $< 1000$ by using computer. The smallest $a > 0$ does not seem to go beyond the product of two largest primes.

REPLY [6 votes]: The number of integers $a$ in $[0, x]$ with the desired property is
$$
2^{-n}\sum_{a=1}^x\prod_{i=1}^n\left(1+\epsilon_i\left(\frac{a}{p_i}\right)\right).
$$
Expand the right hand side to obtain one term $2^{-n} x$, and $2^n-1$ sums of the form $2^{-n}\sum_{a\leq x}\left(\frac{a}{q}\right)$, where $q$ is the product of some of the $p_i$. Since sums over non-trivial characters can be bounded, for $x$ sufficiently large the term $2^{-n} x$ dominates, and we obtain that some $a$ exists. 
To get a bood upper bound on $a$ you need some specific bound on character sums. There are several such bounds, which to use depends on the information you have for the $p_i$. In general one can use Burgess bounds, and obtains that for any $\epsilon>0$ there exists some $C_\epsilon$, such that $a<2^{C_\epsilon n}q^{\frac{1}{4}+\epsilon}$, where $q=\prod p_i$. If the $p_i$ are all small, one should obtain better results from zero-free regions for Dirichlet $L$-series. If the $p_i$ are of different magnitude, then most of the occurring charactersums are much smaller then $\prod p_i$, thus one can reduce the influence of $n$.