(4) Arrange all the simplest proper fractions with a denominator of 24 in ascending order, denoted as $\left.a_{1}\right) a_{2}, \cdots, a_{n}$, then the value of $\sum_{i=1}^{n} \cos \left(a_{i} \pi\right)$ is ( ).
(A) 1
(B) $\frac{1}{2}$
(C) 0
(D) $-\frac{1}{2}$
(4) 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}$,

Notice that
$$
\begin{aligned}
\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,
\end{aligned}
$$

Therefore, $\sum_{i=1}^{n} \cos \left(a_{i} \pi\right)=0$. Hence, the answer is C.