Finding the minimum $n$ such that there are $n$ reals $x_i$ with $\sum_{i=1}^n\sin x_i=0$ and $\sum_{i=1}^ni\sin x_i=2019$ How to solve this problem?

$\sin x_i$ satisfies that, $\left(1\leqslant i\leqslant n\right)$
\begin{equation}
\sum_{i=1}^{n}\sin x_i=0,\qquad \text{where }x_i\in\mathbb{R} 
\end{equation}
Moreover, $\sin x_i$ also satisfies that
\begin{equation}
\sum_{i=1}^{n}i\cdot\sin x_i=2019
\end{equation}
Here is the question. How to find the minimum of $n$, where $n$ is a positive integer?

 A: Consider the following expression, which (assuming $n$ is even) represents $\sum i \cdot \sin(x_i)$ where the first $\frac{n}{2}$ entries satisfy $\sin(x_i) = -1$ and the rest satisfy $\sin(x_i) = 1$, which clearly maximizes your second sum.
The expression, which amounts to adding the first $n$ numbers, then subtracting the first $\frac{n}{2}$ numbers twice (since we don't just want to take them away, we actually want to change the sign on them) is:
$$f(n) = \frac{(n)(n+1)}{2} - 2 \cdot \frac{(\frac{n}{2})(\frac{n}{2}+1)}{2}$$
Suppose $f(n) = 2019$, which would be right-on-the-nose-optimal.  Then you get:
$$\frac{(n)(n+1)}{2} - 2 \cdot \frac{(\frac{n}{2})(\frac{n}{2}+1)}{2} = 2019 \implies \text{multiply by 4}$$
$$2(n)(n+1) - (n)(n+2) = 8076 \implies n^2 = 8076 \implies n = 89.86\text{ish}$$
Since this formula applies to even $n$, it means that $n$ must be greater than $88$.  So it's sufficient to find a solution with $n = 89$.  Note that $(89)(90)/2 - (44)(45) = 2025$ which represents selecting the first $44$ entries so that $\sin(x_i) = -1$ and the rest to $1$.  Zeroing out the middle entry gives us an insufficient sum again, and this is maximal among such sums with $89$ entries.
Thus we are looking for a solution with $n = 90$.  For such a solution, consider $(1/2)(90)(91) - (45)(46) = 2025$, which is setting the first 45 entries to negative and the last $45$ entries to positive.  To decrease this sum by $6$ and achieve our desired $2019$, just swap the signs on $x_{44}$ and $x_{47}$, giving us a solution with $n = 90$, as desired.
