
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_{k}$ be a finite sequence of positive integers not exceeding $n$, where any two adjacent terms are different and there do not exist four indices $p < q < r < s$ such that $a_{p} = a_{r} \neq a_{q} = a_{s}$. Determine the maximum length $k$ of the sequence.

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