10. (20 points) Given a sequence of positive integers $\left\{a_{n}\right\}$ that satisfies the following condition: for any positive integer $n$, if we take several numbers without repetition from the set $\left\{a_{1}, a_{2}, \cdots, a_{n}\right\}$, the absolute values of the numbers obtained by adding and subtracting these numbers are distinct positive integers, and these positive integers, together with $a_{1}, a_{2}, \cdots, a_{n}$, form the set of all positive integers from 1 to $S_{n}$, where $S_{n}$ is the sum of the first $n$ terms of the sequence $\left\{a_{n}\right\}$.
(1) Find the values of $a_{1}, a_{2}$;
(2) Find the general term formula of the sequence $\left\{a_{n}\right\}$.
10. (1) Let $A_{n}=\left\{1,2, \cdots, S_{n}\right\}$, obviously $a_{1}=S_{1}=1$. For $S_{2}=a_{1}+a_{2}=1+a_{2}$, we have
$$
A_{2}=\left\{1,2, \cdots, S_{2}\right\}=\left\{1, a_{2}, 1+a_{2},\left|1-a_{2}\right|\right\}=\{1,2,3,4\} .
$$

Thus, $1+a_{2}=4$, so $a_{2}=3$.
(2) According to the problem, the set $\left\{a_{1}, a_{2}, \cdots, a_{n}\right\}$, following the above rules, generates a total of $S_{n}$ positive integers.
The set $\left\{a_{1}, a_{2}, \cdots, a_{n}, a_{n+1}\right\}$, following the above rules, generates $S_{n+1}$ positive integers, which, in addition to the $S_{n}$ positive integers $1,2, \cdots, S_{n}$, also includes $a_{n+1}, a_{n+1}+i,\left|a_{n+1}-i\right|\left(i=1,2, \cdots, S_{n}\right)$, a total of $2 S_{n}+1$ numbers. Therefore,
$$
S_{n+1}=S_{n}+\left(2 S_{n}+1\right)=3 S_{n}+1 .
$$

Since
$$
S_{n+1}+\frac{1}{2}=3\left(S_{n}+\frac{1}{2}\right)
$$

we have
$$
S_{n+1}=\left(S_{1}+\frac{1}{2}\right) \times 3^{n}-\frac{1}{2}=\frac{1}{2} \times 3^{n+1}-\frac{1}{2} .
$$

Also, when $n \geqslant 2$,
$$
a_{n}=S_{n}-S_{n-1}=\left(\frac{1}{2} \times 3^{n}-\frac{1}{2}\right)-\left(\frac{1}{2} \times 3^{n-1}-\frac{1}{2}\right)=3^{n-1} .
$$

And $a_{1}=1$ also satisfies $a_{n}=3^{n-1}$. Therefore, $a_{n}=3^{n-1}(n \geqslant 1)$.