3 Suppose 2005 line segments are connected end-to-end, forming a closed polyline, and no two segments of the polyline lie on the same straight line. Then, what is the maximum number of intersection points where the polyline intersects itself?


3. Consider a general problem: Let $f(n)$ be the maximum number of intersection points of a broken line with $n$ segments (where $n$ is odd). Starting from a fixed point and moving along the broken line, the segments encountered in sequence are called the 1st, 2nd, ..., $n$-th segments. When drawing the first two segments, there are no intersection points. When drawing the 3rd segment, it can intersect the 1st segment at most once. When drawing the 4th segment, it can intersect the first two segments at most twice. Continuing this way, when drawing the $i$-th segment, it can intersect the previous $i-2$ segments at most $i-2$ times (the $i$-th segment is connected to the $i-1$-th segment and does not intersect with it, and the $i$-th segment does not intersect with itself), where $i=1,2, \cdots, n-1$. Finally, when drawing the $n$-th segment, it can produce at most $n-3$ intersection points, thus the maximum number of intersection points is $\sum_{i=3}^{n-1}(i-2)+(n-3)=\frac{1}{2}(n-2)(n-3)+\frac{1}{2} \cdot 2(n-3)=\frac{1}{2} n(n-3)$. Therefore, $f(n) \leqslant \frac{1}{2} n(n-3)$. On the other hand, when $n$ is odd, there exists an $n$-segment broken line such that $f(n)=\frac{1}{2} n(n-3)$. In fact, take two fixed points $A_{1}$ and $A_{2}$, and draw a circle with $A_{1} A_{2}$ as the diameter. Starting from $A_{1}$, arrange points $A_{1}, A_{3}, \cdots, A_{n}$ in a counterclockwise direction on the semicircle; starting from $A_{2}$, arrange points $A_{2}, A_{4}, A_{6}, \cdots, A_{n-1}$ in a counterclockwise direction on the other semicircle, then the closed broken line $A_{1} A_{2} \cdots A_{n}$ has $\frac{1}{2} n(n-3)$ intersection points. Therefore, the answer to this problem is: $f(2005)=\frac{1}{2}(2005 \times 2002)=$ $2005 \times 1001=2007005$.