10. (20 points) Given the function $f: \mathbf{N} \rightarrow \mathbf{Z}$ satisfies for any natural number $n$,
$$
\begin{array}{l}
|f(n)|=n, \text { and } 0 \leqslant \sum_{k=1}^{n} f(k)<2 n . \\
\text { Find } \sum_{n=1}^{2019} f(n) .
\end{array}
$$
10. Let $S_{n}=\sum_{k=1}^{n} f(k)$. Then $S_{1}=1, S_{2}=3$, and $S_{3}=0$. This problem requires finding $S_{2019}$.
Lemma 1 The function $f(x)$ satisfies
$$
f(n)=\left\{\begin{array}{ll}
n, & S_{n-1}S_{n-1}$, then
$$
\begin{array}{l}
0 \leqslant S_{n-1}+f(n)-n .
\end{array}
$$

Thus, $f(n)=n$.
If $n \leqslant S_{n-1}$, then
$$
\begin{array}{l}
n+f(n) \leqslant S_{n-1}+f(n)n+3$, then $f(n+3)=-n-3$.
Thus, $S_{n+3}=2 n+3+(-n-3)=n$.
We will prove Lemma 2 using mathematical induction.
Assume $S_{n+1}, S_{n+2}, \cdots, S_{n-1+2 j}$ hold, since
$$
\begin{array}{l}
S_{n-1+2 j}=S_{n+1+2(j-1)}=n+1-(j-1) \\
=n+2-j<n+2 j,
\end{array}
$$
$$
\begin{array}{l}
\text { then } f(n+2 j)=n+2 i \text {. } \\
\text { Thus } S_{n+2 j}=(n+2-j)+(n+2 j) \\
=2 n+2+j . \\
\text { Also } S_{n+2 j}=2 n+2+j \\
=(n+2 j+1)+(n+1-j) \\
\geqslant n+2 j+1 \text {, }
\end{array}
$$

Thus, $f(n+2 j+1)=-(n+2 j+1)$.
Then $S_{n+2 j+1}=(2 n+2+j)-(n+2 j+1)$
$$
=n+1-j \text {. }
$$

Lemma 2 is proved.
Thus, when $j=n+1$, $S_{n+1}, S_{n+3}, \cdots$, $S_{n+2 j+1}, \cdots$ decrease to 0 sequentially.

Therefore, if $S_{n}=0$, the next term that is 0 is $S_{3(n+1)}$.
$$
\begin{array}{l}
\text { By } S_{3}=0, S_{3 \times 4}=S_{12}=0, S_{3 \times 13}=S_{39}=0, \\
S_{3 \times 40}=S_{120}=0, S_{3 \times 121}=S_{363}=0, \\
S_{3 \times 364}=S_{1092}=0, \\
2019=1092+2 \times 463+1, \\
\text { Thus } S_{2019}=1092+1-463=630 .
\end{array}
$$