7. Let $S_{n}$ be the sum of the first $n$ terms of the arithmetic sequence $\left\{a_{n}\right\}$, $S_{9}=18, a_{n-4}=30(n>9), S_{n}=$ $336, n=$ $\qquad$ .
7. 21 .
$S_{9}=\frac{9\left(a_{1}+a_{9}\right)}{2}=18$, so $a_{1}+a_{9}=4$, which means $a_{5}=2$. Also, $S_{n}=\frac{n\left(a_{1}+a_{n}\right)}{2}=\frac{n\left(a_{5}+a_{n-4}\right)}{2}$, i.e., $\frac{n}{2}(2+30)=336, n=21$.