12. Given that $a$, $b$, and $c$ are the lengths of the three sides of a right triangle, and for any integer $n$ greater than 2, the equation $\left(a^{n}+b^{n}+c^{n}\right)^{2}=2\left(a^{2 n}+b^{2 n}+c^{2 n}\right)$ holds, then $n=$ $\qquad$.
12. 4 .

Let $x=a^{\frac{n}{2}}, y=b^{\frac{n}{2}}, z=c^{\frac{n}{2}}$, then $0=2\left(a^{2 n}+b^{2 n}+c^{2 n}\right)-\left(a^{n}+b^{n}+c^{n}\right)^{2}=2\left(x^{4}+y^{4}+\right.$ $\left.z^{4}\right)-\left(x^{2}+y^{2}+z^{2}\right)^{2}=x^{4}+y^{4}+z^{4}-2 x^{2} y^{2}-2 y^{2} z^{2}-2 z^{2} x^{2}=-(x+y+z)(x+y-z)(y+$ $z-x)(z+x-y)$. Without loss of generality, assume $c$ is the hypotenuse, then $z>x, z>y$. Thus $x+y+z>0, y+z-x>0, z+$ $x-y>0$, then $z=x+y$, i.e., $\left(\frac{a}{c}\right)^{\frac{n}{2}}+\left(\frac{b}{c}\right)^{\frac{n}{2}}=1$. Also, $a^{2}+b^{2}=c^{2}, 0<\frac{a}{c}<1,0<\frac{b}{c}<$ 1, $y=\left(\frac{a}{c}\right)^{x}+\left(\frac{b}{c}\right)^{x}$ is monotonically decreasing, and there is only one $x$ point where $y=1$, therefore $\frac{n}{2}=2, n=4$.