
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
Let \( a_{1}, a_{2}, \cdots, a_{2015} \) be a sequence of numbers each chosen from \(-1, 0, 1\), satisfying the following conditions:
\[ \sum_{i=1}^{2015} a_{i} = 5 \]
and
\[ \sum_{i=1}^{2015}\left(a_{i}+1\right)^{2}=3040. \]

Let \(\sum_{i=1}^{n} a_{i}\) represent the sum of \(a_{1}, a_{2}, \cdots, a_{n}\). Determine the number of ones in this sequence.

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