
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
Given an arithmetic sequence $\{a_n\}$ with a non-zero common difference, the sum of the first $n$ terms is $S_n$, satisfying that $a_2$, $a_3$, and $a_5$ form a geometric sequence, and $S_6=45$.

$(1)$ Find the general formula for the sequence $\{a_n\}$ and the sum of the first $n$ terms $S_n$;

$(2)$ Let $p_n=\frac{S_{n+2}}{S_{n+1}}+\frac{n-1}{n+1}$, is there a positive integer $M$ such that the inequality $p_1+p_2+\cdots +p_n-2n\leqslant M$ always holds? If it exists, find the minimum value of $M$; if not, explain why.

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