2. If $n \in \mathbf{N}, n \geqslant 2, a_{i} \in\{0,1, \cdots, 9\}$
$$
\begin{array}{l}
(i=1,2, \cdots, n), a_{1} a_{2} \neq 0 \text {, and } \\
\sqrt{a_{1} a_{2} \cdots a_{n}}-\sqrt{a_{2} a_{3} \cdots a_{n}}=a_{1}, \\
\end{array}
$$

then $n=$ $\qquad$, where $\overline{a_{1} a_{2} \cdots a_{n}}$ is the $n$-digit number formed by $a_{1}, a_{2}, \cdots$ $a_{n}$.
2. 2 .

Let $x=\overline{a_{2} a_{3} \cdots a_{n}} \in \mathbf{N}_{+}$. Then $\overline{a_{1} a_{2} \cdots a_{n}}=10^{n-1} a_{1}+x$.
By the given condition, $\sqrt{10^{n-1} a_{1}+x}-\sqrt{x}=a_{1}$. Therefore, $10^{n-1} a_{1}+x=x+a_{1}^{2}+2 a_{1} \sqrt{x}$.
Thus, $10^{n-1}-2 \sqrt{x}=a_{1}$.
If $n \geqslant 3$, then
$$
\begin{array}{l}
10^{n-1}-2 \sqrt{x} \geqslant 10^{n-1}-2 \sqrt{10^{n-1}} \\
=\left(\sqrt{10^{n-1}}-1\right)^{2}-1 \\
\geqslant\left(\sqrt{10^{2}}-1\right)^{2}-1=80,
\end{array}
$$

which contradicts $a_{1} \leqslant 9$.
Therefore, $n=2$.