$p$-th roots of unity summing summing to an integer Let $p$ be an odd prime. Is there an characterization of all sets $S \subset \{1, \cdots, p-1 \}$ such that the term $\displaystyle \left(\sum_{i \in S} e^{\frac{2 \pi i}{p}}\right)\left(\sum_{j \in \{1, \cdots, p-1 \}-S} e^{\frac{2 \pi j}{p}}\right) $ is an integer ?
I know that if $S$ is the set of nonquadratic residues, this is true and I checked using python that this is the only case till $p = 17$, but how do you go on proving this ? 
Remark: This can be shown to equivalent to this problem:

Characterize all splitting of $\{1, \cdots, p-1 \} = S \cup T$ with $S \cap T = \{ \phi \}$ such that the number of solutions to ($x$ is fixed nonzero residue mod $p$) $x \equiv s + t \mod p$ with $s \in S, t \in T$ doesn't depend on $x$


Write $\zeta=\exp(2\pi i/p)$ and $K=\Bbb Q(\zeta)$.
Let $\alpha=\sum_{j\in S}\zeta^j$. As $\sum_{j=1}^{p-1} \zeta^j=-1$, then
your other sum is $-1-\alpha$. So you want $\alpha
(-1-\alpha)=m\in\Bbb Z$, or $\alpha^2+\alpha+m=0$. Thus
$$\alpha=\frac{-1\pm\sqrt{1-4m}}2.$$
There are trivial solutions with $m=0$, and $S=\emptyset$ or $S=
\{1,\ldots,p-1\}$. Suppose we have a non-trivial solution. As the Galois group
of $K/\Bbb Q$ acts transitively on the set $Z=\{\zeta,\zeta^2,\ldots,\zeta^{p-1}\}$, and $Z$ is  a vector space
basis of $K$ over $\Bbb Q$, $\alpha\notin\Bbb Q$
but $\alpha$ generates a quadratic extension of $\Bbb Q$
The only quadratic subfield of the $p$-th cyclotomic is the fixed field
of the $\sigma_{b^2}$ where $\sigma_a$ is the automorphism of $K$ taking
$\zeta\to \zeta^a$ (where $p\nmid a$). Therefore
$$\alpha=\sigma_{b^2}(\alpha)=\sum_{j\in S}\zeta^{b^2j}.$$
For this to  equal $\alpha$ the $\zeta^{b^2j}$ must equal the $\zeta^j$
(for $j\in S$) up to order. The only possibilities are for $S$ to
equal the set of quadratic residues, or the set of quadratic non-residues.
