(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}$