Find the sum of the maximum of the trigonometric polynomial coefficient somedays ago,I have studying and discussing this Maximum Trigonometric polynomial coefficient
problem
Now I want consider a simple problem:
(The sum of the maximum of the trigonometric polynomial coefficient:)  Let $n$ be  give postive integers  If for all real numbers $x$ we have $$f(x)=A_{1}\cos{x}+A_{2}\cos{(2x)}+\cdots+A_{n}\cos{(nx)}\ge -1$$
Find the maximum value of $A_{1}+A_{2}+\cdots+A_{n}$.
Here is what I tried:use this well kown :
$$\sum_{j=0}^{n-1}\xi^k_{j}=\begin{cases}
n&n|k\\
0&otherwise
\end{cases}$$
where $\xi_{i}$be the $n$th roots of unity
let $x_{k}=\dfrac{2k\pi}{n+1},k=0,1,\cdots,n$,so we have
$$\sum_{k=0}^{n}\cos{(mx_{k})}=0,m=1,2,\cdots,n$$
so $$\sum_{k=0}^{n}f(x_{k})=\sum_{m=1}^{n}\sum_{k=0}^{n}A_{m}\cos{(mx_{k})}=0$$
then we have
$$A_{1}+A_{2}+\cdots+A_{n}=f(0)=-\sum_{k=1}^{n}f(x_{k})\le n$$
I Conjecture the maximum is $n$.But I can't find  example such reach this maximum
I have find example for  $n=2$,then let $A_{1}=\dfrac{4}{3},A_{2}=\dfrac{2}{3},A_{1}+A_{2}=2$,then
$$f(x)=\dfrac{1}{3}(2\cos{x}+1)^2-1\ge -1$$
for all postive $n$,I can't find it.Thanks
 A: Solution due to @quasi:
Let $A_k = 2 - \frac{2k}{n+1}$. We have $A_1 + A_2 + \cdots + A_n = n$.
We have
\begin{align}
&\sum_{k=1}^n A_k \cos(kx) + 1\\
=\ & 2\sum_{k=1}^n \cos (kx) - \frac{2}{n+1}\sum_{k=1}^n k \cos (kx) + 1\\
=\ & 2\sum_{k=1}^n \cos (kx) - \frac{2}{n+1}\left(\sum_{k=1}^n \sin (kx)\right)' + 1\\
=\ & 2\left(\frac{-\sin \frac{x}{2} + \sin\frac{(2n+1)x}{2}}{2\sin \frac{x}{2}}\right)
- \frac{2}{n+1}\left(\frac{\cos \frac{x}{2} - \cos \frac{(2n+1)x}{2}}{2\sin \frac{x}{2}}\right)' + 1\\
=\ & \frac{\sin x \cos(nx) + \cos x \sin (nx) - \sin x + \sin(nx)}{\sin x}\\
&\quad - \frac{2}{n+1}\left(\frac{1 + \cos x - \cos(nx) - \cos x \cos (nx) + \sin x \sin (nx)}{2\sin x}\right)' + 1\\
=\ & \frac{1 - \cos((n+1)x)}{(n+1)(1-\cos x)}\\
\ge\ & 0.
\end{align}
Update: We can find $A_k = 2 - \frac{2k}{n+1}$ through the following steps.
Note that when $A_k$ is a polynomial in $k$, $\sum_{k=1}^n A_k \cos(kx)$ has a closed form.
We first try $A_k = a_n + b_n k$.
From $\sum_{k=1}^n A_k = a_n n + \frac{b_n n (n+1)}{2} = n$, we have $a_n + \frac{b_n (n+1)}{2} = 1$.
Thus, $b_n = \frac{2(1-a_n)}{n+1}$.
We need
\begin{align}
\sum_{k=1}^n \left(a_n + \frac{2(1-a_n)}{n+1}k\right) \cos(kx) + 1\ge 0, \ \forall x \in (0, 2\pi). \tag{1}
\end{align}
When $n=2$, (1) becomes
$$\frac{1 - \cos x}{3}(1 + 2\cos x)\Big(a_2 + \frac{4\cos x - 1}{1 - \cos x}\Big) \ge 0, \ \forall x \in (0, 2\pi). \tag{2}$$
It is easy to prove that (2) holds if and only if $a_2 = 2$.
When $n=3$, (1) becomes
$$2\cos x (1 - \cos^2 x)\Big(a_3 + \frac{3\cos x - 2}{1 - \cos x}\Big) \ge 0,  \ \forall x \in (0, 2\pi). \tag{3}$$
It is easy to prove that (3) holds if and only if $a_3 = 2$.
We guess that when $a_n = 2$, (1) holds. Fortunately, it works.
