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? $$


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.
