4. Inside a square, $n$ points are given. They are connected in pairs, as well as individual points with the vertices of the square, but in such a way that no two segments intersect at an interior point. How many segments can be constructed in this way?
Solution. By connecting the points in the described manner, the square is divided into triangles. Let $k$ be the number of these triangles. The sum of the angles of all these triangles is equal to $k \cdot 180^{\circ}$. This sum is equal to $n \cdot 360^{\circ} + 4 \cdot 90^{\circ}$, because the sum of the angles whose common vertex is one of the internal points is equal to $360^{\circ}$, while the sum of the angles whose common vertex is one of the vertices of the square is $90^{\circ}$. Therefore, $k \cdot 180^{\circ} = n \cdot 360^{\circ} + 4 \cdot 90^{\circ}$, i.e., $k = 2n + 2$. Since each constructed segment is a common side of two triangles, and when counting the sides of the triangles, we also count the four sides of the square, we get that the number of constructed segments is

$$
\frac{3(2n+2)-4}{2}=3n+1
$$

## III year