For the vertices of an $n$-sided polygon, we wrote different real numbers such that any written number is the product of the numbers written at the two adjacent vertices.

Determine the value of $n$!
Label the vertices of the polygon in a positive direction from 1 to $n$. For $1 \leq i \leq n$, let the number written at the $i$-th vertex be denoted by $a_{i}$. For any other positive integer $i$, let $a_{i}=a_{i-n}$, meaning $a_{i}$ is the number written at the vertex with number $1 \leq r \leq n$ such that $i=k \cdot n+r$ for some integer $k$.

According to the condition, for every $i$,

$$
a_{i+1}=a_{i} \cdot a_{i+2} \quad \text { and } \quad a_{i+2}=a_{i+1} \cdot a_{i+3}
$$

from which it follows that

$$
a_{i+2}=a_{i} \cdot a_{i+2} \cdot a_{i+3}
$$

The numbers written cannot include 0, because then all numbers would be 0. Thus, from (1), $a_{i} \cdot a_{i+3}=1$, meaning for every $i$,

$$
a_{i}=a_{i+6}
$$

According to the condition, the numbers written are distinct, and since $a_{i+6}$ is the same as $a_{i}$ on the perimeter of the polygon, $n$ must be a divisor of 6.

$n=2$ is clearly not possible. In the case of $n=3$, denoting the numbers by $a, b, c$, we have $a=b c, b=c a, c=a b$, which means

$a^{2}=b^{2}=c^{2}=a b c$. The absolute values of the three numbers are equal, and thus at least two of them are the same, so the condition does not hold for $n=3$.

If $n=6$, then the numbers written in this order, $a, a b, b, 1 / a, 1 / a b, 1 / b$, satisfy the condition, provided that $a$ and $b$ are distinct from each other and from 1, (-1), and 0.

Therefore, in the problem, the value of $n$ can only be 6.