$4-$

Each side of an equilateral triangle is divided into n equal parts. Lines are drawn through the division points parallel to the sides. As a result, the triangle is divided into $n^{2}$ small triangles. We call a chain a sequence of small triangles in which no triangle appears more than once and each subsequent triangle shares a side with the previous one. What is the maximum possible number of triangles in a chain?
To prove what often happens in olympiads, it is enough to make one unexpected move: color the triangles in a checkerboard pattern, as shown in the figure. The rest is quite simple. In the entire triangle, there are

![](https://cdn.mathpix.com/cropped/2024_05_06_62351a5cb646b08ac6fbg-25.jpg?height=661&width=760&top_left_y=527&top_left_x=1232)
n more red triangles than yellow ones (in each horizontal row, there is one more red triangle), and in the chain, the colors must alternate, so there can only be one more red triangle than yellow ones. One of the longest possible chains is shown in the figure. (From the above, it is clear that for a chain to have a length of $n^{2} - n + 1$, it is necessary and sufficient that it starts and ends in red triangles and passes through all yellow triangles without exception.)

## Answer

$n^{2}-n+1$.