Example 9 Given a positive integer $a$, let $X=\left\{a_{1}, a_{2}, a_{3}, \cdots, a_{n}\right\}$ be a set of positive integers, where $a_{1} \leqslant a_{2} \leqslant a_{3} \leqslant \cdots \leqslant a_{n}$. If for any integer $p(1 \leqslant p \leqslant a)$, there exists a subset $A$ of $X$ such that $S(A)=p$, where $S(A)$ is defined as the sum of the elements in set $A$, find the minimum value of $n$. (Original problem)
To study special cases, for $a=1,2,3,4$, we conduct experiments and obtain the corresponding minimum values $n=1,2,2,3$, and from this, we discover that the set $X=\left\{a_{1}, a_{2}, a_{3}, \cdots, a_{n}\right\}$, which makes $n$ reach its minimum, has the following property: for any $i=1,2, \cdots, n$, we have $a_{i} \leqslant 2^{i-1}$.

In fact, suppose there exists $i (1 \leqslant i \leqslant n)$ such that $a_{i} \geqslant 2^{i-1}+1$, and let $i$ be the smallest such $i$ (extreme assumption), i.e., $a_{1} \leqslant 2^{0}, a_{2} \leqslant 2^{1}, a_{3} \leqslant 2^{2}, \cdots, a_{i-1} \leqslant 2^{i-2}$, and $a_{i} \geqslant 2^{i-1}+1$. Then, for any subset $A$ of $X$ that does not contain any elements from $a_{i}, a_{i+1}, \cdots, a_{n}$, we have $S(A) \leqslant a_{1}+a_{2}+\cdots+a_{i-1} \leqslant 2^{0}+2^{1}+2^{2}+\cdots+2^{i-2}=2^{i-1}-1$, and for any subset $A$ of $X$ that contains at least one element from $a_{i}, a_{i+1}, \cdots, a_{n}$, we have $S(A) \geqslant a_{i} \geqslant 2^{i-1}+1$. Therefore, there does not exist a subset $A$ of $X$ such that $S(A)=2^{i-1}$, so $a \leqslant 2^{i-1}-1$.

Since the sums of the subsets of $X$ cover $1,2, \cdots, a$, and for any subset $A$ of $X$ that contains at least one element from $a_{i}, a_{i+1}, \cdots, a_{n}$, we have $S(A)>a$, the sums of the subsets of $X \backslash\left\{a_{i}, a_{i+1}, \cdots, a_{n}\right\}$ also cover $1,2, \cdots, a$, which contradicts the minimality of $n$.

For a given $a$, let $2^{r} \leqslant a<2^{r+1}$. If $n \leqslant r$, then because $a_{i} \leqslant 2^{i-1} (i=1,2, \cdots, n)$, for any subset $A$ of $X$, we have $S(A) \leqslant S(X)=a_{1}+a_{2}+\cdots+a_{n} \leqslant 2^{0}+2^{1}+2^{2}+\cdots+2^{n-1}=2^{n}-1 \leqslant 2^{r}-1<2^{r} \leqslant a$, so there does not exist a subset $A$ of $X$ such that $S(A)=a$, which is a contradiction. Therefore, $n \geqslant r+1$.

When $n=r+1$, let $a_{i}=2^{i-1} (i=1,2, \cdots, r)$, and $a_{r+1}=a+1-2^{r}$. We will prove that $X=\left\{a_{1}, a_{2}, a_{3}, \cdots, a_{r+1}\right\}$ satisfies the condition.

In fact, by binary representation, the sums of the subsets of $\left\{a_{1}, a_{2}, a_{3}, \cdots, a_{r}\right\}$ cover $1,2, \cdots, 2^{r}-1$, and the sums of the subsets of $X$ that contain $a_{r+1}$ cover $a_{r+1}, a_{r+1}+1, a_{r+1}+2, \cdots, a_{r+1}+2^{r}-1=a$. Since $2^{r} \leqslant a \leqslant 2^{r+1}$, we have $a_{r+1}=a+1-2^{r}<2^{r+1}+1-2^{r}=2^{r}+1$, so $a_{r+1} \leqslant 2^{r}$. Therefore, the sums of the subsets of $X$ cover $1,2, \cdots, a$.

In summary, the minimum value of $n$ is $r+1$, where $r=\left[\log _{2} a\right]$.