Sum of $1- \cos\theta_i$ is bounded 
For each $i=1,\ldots,N$, let $\theta_i\geq 0$ be angles such that $\sum_{i=1}^{N}\theta_i \leq \pi$. Prove that 
  $$
\sum_{i=1}^{N}(1-\cos\theta_i) \leq 2.
$$

When trying to solve an olympiad geometry problem, I had an idea that was reduced to this question. Is this inequality true? I tried to approach it using convexity, but didn't get anything satisfactory.
(I checked some small examples and think the result is correct).
 A: Prove the sharper inequality
$$\sum_{i = 1}^k (1 - \cos \theta_i) \leqslant 1 - \cos \sigma_k$$
for $1 \leqslant k \leqslant N$, where
$$\sigma_k = \sum_{i = 1}^k \theta_i.$$
The base case is clear, and for the induction step, one must show that
$$1 - \cos \theta \leqslant \cos \sigma - \cos (\sigma + \theta)$$
for $\theta,\sigma \geqslant 0$ and $\sigma + \theta \leqslant \pi$. Geometrically that is clear by looking at the circle, the projection of an arc of fixed length in the upper semicircle to the $x$-axis is shortest when the arc is at the ends of the semicircle. Analytically, the assertion is
$$2 \sin^2 \frac{\theta}{2} \leqslant 2\sin \frac{\sigma+\theta}{2}\sin\frac{\theta}{2},$$
i.e. $\sin \frac{\theta}{2} \leqslant \sin \frac{\sigma+\theta}{2}$, which follows since $\frac{\theta}{2} \leqslant \frac{\sigma + \theta}{2} \leqslant \frac{\pi}{2}$.
A: Let $\theta_i=2\varphi_i$. We want to show that the constraints $\varphi_i\geq 0$ and $\sum\varphi_i=\frac{\pi}{2}$ imply
$$ f(\varphi_1,\ldots,\varphi_n)=\sum \sin^2\varphi_i \leq 1. $$
We may notice that if $\varphi_a,\varphi_b\geq \frac{\pi}{4}$ then $2\sin^2\left(\frac{\varphi_a+\varphi_b}{2}\right)\geq \sin^2\varphi_a+\sin^2\varphi_b$. By mixing variables, we may assume that all the angles among $\varphi_1,\ldots,\varphi_n$ with amplitude $\geq\frac{\pi}{4}$ are equal, or
$$ \varphi_1\leq\ldots\leq\varphi_m\leq\frac{\pi}{4},\qquad \varphi_{m+1}=\ldots=\varphi_n\geq \frac{\pi}{4}.$$
On the interval $\left[0,\frac{\pi}{4}\right]$ the function $\sin^2(x)$ is convex, hence the maximum of $\sum_{k=1}^{m}\sin^2(\varphi_k)$ under the constraints $\varphi_k\geq 0$ and $\sum_{k=1}^{m}\varphi_k = \pi-(n-m)\varphi_n$ is attained at the boundary of such domain. In other terms, we may assume without loss of generality 
$$\{\varphi_1,\ldots,\varphi_n\}\subseteq \{0,\theta,\Theta\}$$
where $\theta\leq\frac{\pi}{4}$ and $\Theta\geq\frac{\pi}{4}$. Thus the original problem boils down to an inequality in just two variables, that is straightforward to prove.
