4. Given a positive integer $n$, let $a_{1}, a_{2}, \cdots, a_{n}$ be a sequence of non-negative integers. If the arithmetic mean of some consecutive terms (which can be a single term) is not less than 1, then these terms are called a "dragon", where the first term is called the "dragon head" and the last term is called the "dragon tail". It is known that each term in $a_{1}, a_{2}, \cdots, a_{n}$ is either a dragon head or a dragon tail. Find the minimum value of $\sum_{i=1}^{n} a_{i}$.
（Zou Jin provided the problem）
4. The minimum value of $\sum_{i=1}^{n} a_{i}$ is $\left[\frac{n}{2}\right]+1$, where $[x]$ denotes the greatest integer not exceeding the real number $x$.
First, provide a construction:
When $n=2 k-1$, let $a_{k}=k$, and all other terms be 0;
When $n=2 k$, let $a_{k}=k, a_{2 k}=1$, and all other terms be 0.
It is easy to verify that in this sequence, each term is either a head or a tail, and
$$
\sum_{i=1}^{n} a_{i}=\left[\frac{n}{2}\right]+1 .
$$

Next, we use mathematical induction to prove: For any sequence $a_{1}, a_{2}, \cdots, a_{n}$ that meets the requirements, we have
$$
\sum_{i=1}^{n} a_{i} \geqslant\left[\frac{n}{2}\right]+1 .
$$

When $n=1$, the conclusion is obviously true.
Assume the conclusion holds for all sequences with fewer than $n$ terms, consider an $n$-term sequence $a_{1}, a_{2}, \cdots, a_{n}$, where each term is either a head or a tail.

Let the longest dragon starting with $a_{1}$ have $t$ terms. If $t \geqslant\left[\frac{n}{2}\right]+1$, then the conclusion holds.
If $t \leqslant\left[\frac{n}{2}\right]$, by the fact that $a_{1}, a_{2}, \cdots, a_{t}$ is the longest dragon, we have
$$
\begin{array}{l}
a_{1}+a_{2}+\cdots+a_{t}=t, \text { and } a_{t+1}=0 . \\
\text { Let } b_{1}=a_{t+1}+a_{t+2}+\cdots+a_{2 t}, \\
b_{2}=a_{2 t+1}, b_{3}=a_{2 t+2}, \cdots, b_{n-2 t+1}=a_{n} .
\end{array}
$$

We now prove: In the sequence $b_{1}, b_{2}, \cdots, b_{n-2 t+1}$, for $1 \leqslant$ $i \leqslant n-2 t+1, b_{i}$ is either a head or a tail.
If $a_{i+2 t-1}$ is a head, then $b_{i}$ is also a head;
If $a_{i+2 t-1}$ is a tail, then there exists a positive integer $m$ such that
$$
a_{m}+a_{m+1}+\cdots+a_{i+2 t-1} \geqslant i+2 t-m \text {. }
$$

We classify the value of $m$ as follows.
(1) When $m \geqslant 2 t+1$, we have
$$
\begin{array}{l}
b_{m-2 t+1}+b_{m-2 t+2}+\cdots+b_{i} \\
=a_{m}+a_{m+1}+\cdots+a_{i+2 t-1} \\
\geqslant i+2 t-m,
\end{array}
$$

Thus, $b_{i}$ is a tail;
(2) When $t+1 \leqslant m \leqslant 2 t$, we have
$$
\begin{array}{l}
b_{1}+b_{2}+\cdots+b_{i} \\
\geqslant a_{m}+a_{m+1}+\cdots+a_{i+2 t-1} \\
\geqslant i+2 t-m \geqslant i,
\end{array}
$$

Thus, $b_{i}$ is a tail;
(3) When $m \leqslant t$, we have
$$
\begin{array}{l}
b_{1}+b_{2}+\cdots+b_{i} \\
=a_{1}+a_{2}+\cdots+a_{i+2 t-1}-t \\
\geqslant i+2 t-m-t \geqslant i,
\end{array}
$$

Thus, $b_{i}$ is also a tail.
Therefore, in the sequence $b_{1}, b_{2}, \cdots, b_{n-2 t+1}$, by the induction hypothesis, we have
$$
\begin{array}{l}
\sum_{i=1}^{n-2 i+1} b_{i} \geqslant\left[\frac{n-2 t+1}{2}\right]+1 . \\
\text { Hence } \sum_{i=1}^{n} a_{i}=t+\sum_{i=1}^{n-2 t+1} b_{i} \\
\geqslant t+\left[\frac{n-2 t+1}{2}\right]+1 \\
\geqslant\left[\frac{n}{2}\right]+1 .
\end{array}
$$

The conclusion holds for an $n$-term sequence.
In summary, the minimum value of $\sum_{i=1}^{n} a_{i}$ is $\left[\frac{n}{2}\right]+1$.