A26 (19-2, Vietnam) In a finite sequence of real numbers, the sum of any 7 consecutive terms is negative, while the sum of any 11 consecutive terms is positive. How many terms can such a sequence have at most?

Translate the above text into English, please retain the original text's line breaks and format, and output the translation result directly.
Let's first prove that $n \geqslant 17$ is impossible. We use proof by contradiction. Suppose the sequence is $a_{1}$, $a_{2}, \cdots, a_{17}, \cdots, a_{n}$.
From the given conditions, we have
$$
\begin{array}{c}
a_{k}+a_{k+1}+a_{k+2}+\cdots+a_{k+6} < 0.
\end{array}
$$

Subtracting two such inequalities, we get
$$
a_{k+7}+a_{k+8}+a_{k+9}+a_{k+10} > 0.
$$

Thus, starting from the eighth term, the sum of any four consecutive terms is positive, so we have
$$
\begin{aligned}
& a_{8}+a_{9}+a_{10}+2 a_{11}+a_{12}+a_{13}+a_{14} \\
= & \left(a_{8}+a_{9}+a_{10}+a_{11}\right)+\left(a_{11}+a_{12}+a_{13}+a_{14}\right) \\
> & 0.
\end{aligned}
$$

But from the condition, we know
$$
a_{8}+a_{9}+a_{10}+a_{11}+a_{12}+a_{13}+a_{14} < 0.
$$
Similarly,
$$
a_{12} > 0, a_{13} > 0,
$$

Thus,
$$
a_{11}+a_{12}+a_{13} > 0,
$$

But
$$
a_{11}+a_{12}+a_{13}+\cdots+a_{17} < 0,
$$

Hence,
$$
a_{14}+a_{15}+a_{16}+a_{17} < 0,
$$

This contradicts (1), so $n < 17$, i.e., $n \leqslant 16$.
When $n=16$, a construction that satisfies the above conditions exists, and can be constructed as follows:
Let
$$
\begin{array}{c}
S_{1}=a_{1}, \\
S_{2}=a_{1}+a_{2}, \\
\cdots \cdots \\
S_{16}=a_{1}+a_{2}+\cdots+a_{16}.
\end{array}
$$

The conditions are essentially
$$
\begin{aligned}
& S_{10}<S_{3}<S_{14}<S_{7}<0<S_{11}<S_{4}<S_{15}<S_{8}<S_{1}<S_{12}<S_{5} \\
< & S_{16}<S_{9}<S_{2}<S_{13}<S_{6}.
\end{aligned}
$$

And this is both necessary and sufficient. (In fact, this also proves that $S_{17}$ does not exist, otherwise $S_{6}<S_{17}<S_{10}<S_{6}$, which is a contradiction)
Thus, constructing $a_{1}, a_{2}, \cdots, a_{16}$ is very straightforward, for example, $S_{10}=-4, S_{3}=-3$,
$$
\begin{array}{l}
S_{14}=-2, S_{7}=-1, S_{11}=1, S_{4}=2, S_{15}=3, S_{8}=4, S_{1}=5, S_{12}=6, S_{5}= \\
7, S_{16}=8, S_{9}=9, S_{2}=10, S_{13}=11, S_{6}=12.
\end{array}
$$

Solving, we get $\left(a_{1}, a_{2}, a_{3}, a_{4}, \cdots, a_{16}\right)=(5,5,-13,5,5,5,-13,5,5,-13, 5,5,5,-13,5,5)$.