Example 6 Let $n>6$, all positive integers not greater than $n$ and coprime with $n$
$$
1=a_{1}<a_{2}<\cdots<a_{\varphi(n)}=n-1
$$

form an arithmetic sequence exactly. Find $n$.
【Analysis】When $n>6$, $\varphi(n) \geqslant 3$.
When the common difference $d=1$, all positive integers not greater than $n$ are coprime with $n$, i.e., $n$ is a prime number greater than 6.

When $d=2$, all positive odd numbers not greater than $n$, $1,3,5, \cdots$, $n-1$ are coprime with $n$.
Thus, $n=2^{\alpha}(\alpha \geqslant 3)$.
When $d \geqslant 3$, we have $a_{1}=1, a_{2}=1+d \geqslant 4$.
Therefore, $2 \mid n$, and $3 \mid n$.
If $d \equiv 1(\bmod 3)$, then $3 \mid(1+2 d)$, i.e., $3 \mid a_{3}$, which contradicts 3 being coprime;

If $d \equiv 2(\bmod 3)$, then $3 \mid(1+d)$, i.e., $3 \mid a_{2}$, which contradicts 3 being coprime.
Thus, $3 \mid d$.
Hence, $a_{\varphi(n)}=n-1=1+(\varphi(n)-1) d \equiv 1(\bmod 3)$, which contradicts $3 \mid n$.

In summary, the $n$ that satisfies the conditions of the problem is a prime number greater than 6 or an integer power of 2.

【Note】The common difference of an arithmetic sequence is very important. A considerable portion of the solutions to math competition problems involving arithmetic sequences and number theory are developed by discussing the values of the common difference.