If $\tan(x_1) \cdots\tan(x_n)=1$ for acute $x_i$, then does it follow that $\cos(x_1)+\cdots+\cos(x_n) \leq n\sqrt{2}/2$? It is easily seen that if $x,y\in[0,\pi/2)$ satisfy $\tan(x)\tan(y)=1$, then $$\cos(x)+\cos(y)\le\sqrt 2$$
A much more delicate fact is that if $\tan(x)\tan(y)\tan(z)=1$ (while $0\le x,y,z<\pi/2$), then 
$$\cos(x)+\cos(y)+\cos(z)\le \frac{3\sqrt 2}2$$
I can prove this, but the proof is a little complicated; can anybody suggest a nice, simple proof?

As a generalization, suppose that $n\ge 4$, $x_1,\dotsc,x_n\in[0,\pi/2)$, and $\tan(x_1)\dotsb\tan(x_n)=1$. Does it follow that
    $$ \cos(x_1)+\dotsb+\cos(x_n) \le \frac{n\sqrt 2}2? $$

 A: For three variables we ca use C-S:
Let $\tan{x}=\sqrt{\frac{b}{a}},$ $\tan{y}=\sqrt{\frac{c}{b}},$ where $a$, $b$ and $c$ are positives.
Thus, $\tan{z}=\sqrt{\frac{a}{c}}$ and by C-S we obtain:
$$\sum_{cyc}\cos{x}=\sum_{cyc}\frac{1}{\sqrt{1+\tan^2x}}=\sum_{cyc}\sqrt{\frac{a}{a+b}}\leq$$
$$\leq\sqrt{\sum_{cyc}\frac{a}{(a+b)(a+c)}\sum_{cyc}(a+c)}\leq\frac{3}{\sqrt2},$$
where the last inequality it's just $$\sum_{cyc}c(a-b)^2\geq0.$$
The generalization is wrong for all $n\geq4$.
Try $x_1=x_2=...=x_{n-1}\rightarrow0^+$ and $x_n\rightarrow\frac{\pi}{2}^-$
A: After the substitutions described in the comments ($cos(x_i) \rightarrow \sqrt{\frac{1}{1+tg^2(x_i)})}$ and $e^{a_i}=tg(x_i)$, one sees that needs to maximize:
$f(x)=\sum_{i=1}^{n}  \sqrt{\frac{1}{1+e^{2x_i}})}$
subject to:
$\sum_i x_i=0$
over the domain $x \in R^n$.
This sounds like a job for Lagrange mulipliers but I was not able to solve the system. For the moment I observe that the conjecture is equivalent to having maximum for $x_i=0$ and I want to show that this is not the case for large $n$. Indeed $f(0,...0)=n\sqrt{2}/2$, but $f(-m,-m,...,-m,(n-1)m)\rightarrow (n-1)$ for large m. The second term dominates for large $n$ and therefore the thesis cannot be true.
