
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 geometric sequence $\{a_n\}$, where $a_n > 0$ ($n\in\mathbb{N}^*$) and the common ratio $q\in(0,1)$, it is given that $a_1a_5+2a_3a_5+a_2a_8=25$, and $2$ is the geometric mean of $a_3$ and $a_5$,
$(1)$ Find the general formula for the sequence $\{a_n\}$;
$(2)$ Let $b_n=\log_2a_n$, and the sum of the first $n$ terms of the sequence $\{b_n\}$ be $S_n$. When $\frac{S_1}{1}+ \frac{S_2}{2}+\ldots+ \frac{S_n}{n}$ is maximized, find the value of $n$.

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