9. Arrange $1,2, \cdots, 7$ in a row such that the sum of the first term, the sum of the first two terms, the sum of the first three terms, ... up to the sum of all seven terms are not divisible by 3. Then there are $\qquad$ different arrangements.
(Thailand)
9. 360 .

Notice that, $3 \equiv 6 \equiv 0(\bmod 3)$, $4 \equiv 7 \equiv 1(\bmod 3), 5 \equiv 2(\bmod 3)$.
Therefore, it is necessary to check whether the partial sums can be divided by 3 seven times, with the remainder being 1 or 2 each time.
Obviously, adding 3 or 6 to the next term will not change the remainder:
If the current remainder is 1, only 1, 4, or 7 can be added to the next term, so the remainder becomes 2;
If the current remainder is 2, only 2 or 5 can be added to the next term, so the remainder becomes 1.
When the first term is not 3 or 6: If the first term is 2 or 5, the remainder can change from 1 to 2 three times, while the remainder can only change from 2 to 1 once, which is impossible.
Therefore, the first term can only be 1, 4, or 7, changing the remainder from 1 to 2 twice, and from 2 to 1 also twice, with the other two times the remainder remains unchanged. Thus, when the remainder does not change, the overall form is completely determined, and there are $\mathrm{C}_{6}^{2}=15$ forms.
For each form, the numbers 1, 4, 7 have $3!=6$ permutation methods, the numbers 2, 5 have two permutation methods, and the numbers 3, 6 have two permutation methods, so the total number of different permutation methods is
$$
15 \times 6 \times 2 \times 2=360 \text {. }
$$