We know that $$2\cos k _1 x \cdot\cos k_2x = \cos(k_1+k_2)x + \cos (k_1-k_2)x$$
How can we write the product of $n$ cosines?
$$4 \cos k _1 x \cdot\cos k_2x \cdot \cos k_3 x =\cos(k_1+k_2+k_3)x \\+\cos(-k_1+k_2+k_3)x +\cos(k_1-k_2+k_3)x \\+\cos(k_1+k_2-k_3)x $$
$$8 \cos k _1 x \cdot \cos k_2x\cos k_3 x\cdot \cos k_4x=\cos(k_1+k_2+k_3+k_4)x\\+\cos(-k_1+k_2+k_3+k_4)x+\cos(k_1-k_2+k_3+k_4)x\\+\cos(k_1+k_2-k_3+k_4)x+\cos(k_1+k_2+k_3-k_4)x\\+\cos(-k_1+k_2+k_3-k_4)x+\cos(k_1-k_2+k_3-k_4)x\\+\cos(k_1+k_2-k_3-k_4)x$$
$$2^n \cos k _1 x \cdot\cos k_2x\cdots \cos k_n x=?$$
Using Euler formula for $\cos$,
$$P:=2^{n-1}\prod_{m=1}^{n}\left(\dfrac{e^{ik_m}+e^{-ik_m}}{2}\right) \\ =\dfrac12\prod_{m=1}^{n}\left(e^{ik_m}+e^{-ik_m}\right)$$
$$=\dfrac12\sum e^{i s_1k_1+is_2k_2\cdots +i s_nk_n}=\dfrac12\sum_{s \in \{-1,1\}^n}e^{i \ s \bullet p}$$
where $s:=(s_1,s_2,\cdots s_n)=(\pm1,\pm1,\cdots \pm1) \in \{-1,1\}^n$.
where $\bullet$ is the symbol for dot product.
Pairing the terms associated with $s$ and $-s$:
$$P:=\dfrac12 \sum(e^{i \ s \bullet p}+e^{-i \ s \bullet p})= \sum \cos(s \bullet p)$$
where the previous sums are extended to all $s$ such that if $s \in \{-1,1\}^n$ has already been used, $-s$ will not be used, in conformity with the results obtained so far for $n=2,3,4.$