
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 consisting of positive integers not exceeding \(n\), where no two adjacent terms are the same and there do not exist any four indices \(p < q < r < s\) such that \(a_{p} = a_{r} \neq a_{q} = a_{s}\).

Find the maximum value of the number of terms \(k\).

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