This is a too long remark:
- The problem is similar to the lonely runner conjecture:
Lonely runner conjecture $$max_{t\in \mathbb R}( min_{v_1,...,v_j\in[0,1]} ( min_{1\leq i\leq n} \|v_it\|_{\mathbb Z})) = \frac{1}{n+1}$$$$\max_{t\in \mathbb R}( \min_{v_1,...,v_j\in[0,1]} ( \min_{1\leq i\leq n} \|v_it\|_{\mathbb Z})) = \frac{1}{n+1}$$ Where $v_i=\frac{q_i}{p_i}\in \mathbb Q$, $\forall 1\leq i\leq n$.
The point is $\sin(x)=\Im(e^{ix})$, so take $$g_n(x)=\sin(a_1x)+...+\sin(a_nx)$$ Then $g_n(x)=\sum_{1\leq j\leq n}\Im(e^{ia_jx})$. We could understand, $$\Im:\mathbb S_1\to [-1,1]$$ As a deformation of metric space with small distortion.
It is not difficult to find the nontrivial part of your problem must assume $a_i$ is a rational multiplier of $\pi,\,\forall 1\leq i\leq n$. By the continued fractional argument or Dirichlete's approximation theorem you could always change your number from an irrational multiplier of $\pi$ to a rational multiplier of $\pi$ to optimize your tuple $(a_1,...,a_n)$, because we only need to consider the worst situation.
Now if lonely runner conjecture is true we could say some thing for your problem, due to it carollay is there $\exists x$ such that $\{\pi a_ix\}$ constitute the vertex of a $n$ regular polygon on $S^1$, at this point, the value $g_n(x)=0$ and so we know $g_n'(x)\geq 0$.
in fact we can get some lower bound estimate of $g_n(x)$ by combine a nontrivial estimate of Lonely runner conjecture, but this estimate always less than 0, so do not handle this problem and until now there is only more or less trivial estimate of LRC.
Forgive me, I can not go further temporarily...