5. a) Let's consider a hexagon with numbers inscribed that satisfy the conditions of the problem. Since not all numbers are the same, there exist two adjacent vertices such that one has the number -1 and the other has 1; let these be \(A\) and \(B\), respectively, and let the next vertices be \(C, D, E\), and \(F\). Then, in \(C\) there must be 1 (so that the product of the numbers in \(A, B\), and \(C\) is -1), then in \(D\) there must be -1 (due to \(B, C\), and \(D\)), then in \(E\) there must be 1 (due to \(C, D\), and \(E\)), and finally in \(F\) there must be 1. Therefore, the sum is \(-1 + 1 + 1 + (-1) + 1 + 1 = 2\).

b) As in part a), we find vertices \(A_{1}\) and \(A_{2}\) where the numbers -1 and 1 are inscribed, respectively. Then in vertex \(A_{3}\) there must be the number 1, then in vertex \(A_{4}\) the number -1, then in vertex \(A_{5}\) the number 1, in \(A_{6}\) the number 1, in \(A_{7}\) the number -1, and so on. We observe that the pattern repeats, i.e., the number -1 is always inscribed in vertices whose index gives a remainder of 1 when divided by 3 (in other words, every third vertex), and the number 1 is inscribed in all other vertices. Therefore, in \(\frac{2019}{3}\), i.e., 673 vertices, the number -1 is inscribed, and in the remaining 1346 vertices, the number 1, so the sum of all inscribed numbers is: \(673 \cdot (-1) + 1346 \cdot 1 = 673\).

## Fourth Grade - B Category
5. At each vertex of a regular $n$-gon, a number 1 or -1 is inscribed, with not all $n$ numbers being equal. The product of the numbers inscribed in any 3 consecutive vertices is -1. Determine the sum of all inscribed numbers for:
a) $n=6$;
b) $n=2019$.

## Fourth grade - B category