4. Arrange all the simplest proper fractions with a denominator of 24 in ascending order, which are $a_{1}, a_{2}, \cdots, a_{n}$. Then the value of $\sum_{i=1}^{n} \cos a_{i} \pi$ is ( ).
(A) 1
(B) $\frac{1}{2}$
(C) 0
(D) $-\frac{1}{2}$
4.C.

All the simplest proper fractions with a denominator of 24 are
$$
\frac{1}{24}, \frac{5}{24}, \frac{7}{24}, \frac{11}{24}, \frac{13}{24}, \frac{17}{24}, \frac{19}{24}, \frac{23}{24} \text {. }
$$

Notice that
$$
\begin{array}{l}
\frac{1}{24}+\frac{23}{24}=\frac{5}{24}+\frac{19}{24}=\frac{7}{24}+\frac{17}{24}=\frac{11}{24}+\frac{13}{24}=1 . \\
\text { Therefore } \sum_{i=1}^{n} \cos a_{i} \pi=0 .
\end{array}
$$