
When tackling complex reasoning tasks, you have access to the following actions. Use them as needed to progress through your thought process.

[ASSESS]

[ADVANCE]

[VERIFY]

[SIMPLIFY]

[SYNTHESIZE]

[PIVOT]

[OUTPUT]

You should strictly follow the format below:

[ACTION NAME]

# Your action step 1

# Your action step 2

# Your action step 3

...

Next action: [NEXT ACTION NAME]


system
In the sequence \(\{a_n\}\), let \(S_n = \sum_{i=1}^{n} a_i\) (with \(n \in \mathbb{Z}_+\)), and it is agreed that \(S_0=0\). It is known that
\[ 
a_k = 
\begin{cases} 
k, & \text{if } S_{k-1} < k; \\
-k, & \text{if } S_{k-1} \geq k 
\end{cases} 
\quad (1 \leq k \leq n, k, n \in \mathbb{Z}_+).
\]
Find the largest positive integer \(n\) not exceeding 2019 such that 
\[ 
S_n = 0. 
\]

Present the answer in LaTex format: \boxed{Your answer}
user