<s>[INST] Maximum value of $\sqrt{1-\sqrt{a_1}} + \sqrt{1-\sqrt{a_2}} + \cdots + \sqrt{1-\sqrt{a_n}}$ for $a_i \in [0,1], a_1+a_2+ \cdots +a_n = 2$ 
Given $n \ge 3$ real numbers $a_1, a_2, \cdots, a_n \in [0,1]$ such that $a_1 + a_2+ \cdots +a_n =2$, find the maximum value of:
$$P =\sqrt{1-\sqrt{a_1}} + \sqrt{1-\sqrt{a_2}} + \cdots + \sqrt{1-\sqrt{a_n}}.$$

So far my only guess is that the equality occurs when there are $n-x$ numbers equal to $0$ and $x$ numbers equal to $\dfrac{2}{x}$, then we have:
$$P \le n-x + x \sqrt{1-\sqrt{\frac{2}{x}}} = n-x + \sqrt{x^2-x\sqrt{2x}}$$
The function above reaches maximum at $x=3$, so we have:
$$P \le n-3 + \sqrt{9 -3\sqrt{6}} $$
And I didn't know how to proceed any further.
 [/INST] Hint : use the EV method with :
$$f(x)=\sqrt{1-\sqrt{1-\frac{x}{x+1}}}$$
We have on $(0,\infty)$:
$$f'''(x)>0$$
With the constraint (for $0<x_i\leq 1$):
$$\sum_{i=1}^{n}\frac{1-x_i}{x_i}=2\,,\sum_{i=1}^{n}\left(\frac{1-x_i}{x_i}\right)^2=\operatorname{constant}$$
Now use corollary 1.4 (see http://emis.maths.adelaide.edu.au/journals/JIPAM/images/059_06_JIPAM/059_06_www.pdf )
</s>