2. Set $A$ is a subset consisting of 40 elements from $\{1,2, \cdots, 50\}$, and $S$ is the sum of all elements in set $A$. Then the number of possible values for $S$ is $\qquad$ .
2.401.
Notice that,
the minimum value of $S$ is $1+2+\cdots+40=820$,
the maximum value of $S$ is $11+12+\cdots+50=1220$.
Let the element $k$ in set $A$ be the smallest element such that $k+1$ is not an element of set $A$.

If $S \leqslant 1219$, then $k \neq 50$, replace $k$ with $k+1$, to get a subset $B$ consisting of 40 elements, whose sum is $S+1$.
Thus, the number of possible values for $S$ is
$1220-820+1=401$.