Four, (This question is worth 18 points) Pingxi Given $n$ points $A_{1}$, $A_{2}$, ..., $A_{n}(n \geqslant 3)$, no three points are collinear. By selecting $k$ pairs of points to determine $k$ lines (i.e., drawing a line through each pair of points among the $k$ pairs), ensure that these $k$ lines do not intersect to form a triangle with all vertices being the given points. Find the maximum value of $k$.

---

Here is the translation, maintaining the original text's line breaks and format.
If a straight line $l$ connects two points (let's denote them as $A_{1}$ and $A_{2}$), the restriction that no such two lines intersect to form a triangle means that these two points cannot simultaneously connect to any of the remaining $n-2$ points. That is, the number of lines passing through $A_{1}$ and $A_{2}$ is at most $n-1$ (including line $l$).

Similarly, for the $n-2$ points $A_{3}, A_{4}, \cdots, A_{n}$, the number of lines passing through any one of $A_{3}$ and $A_{4}$ is at most $n-3$, and so on. Thus,
$$
\begin{array}{l}
k \leqslant(n-1)+(n-3)+(n-5)+\cdots \\
=\left\{\begin{array}{r}
(n-1)+(n-3)+\cdots+1=\frac{n^{2}}{4}, \\
\text { if } n \text { is even; } \\
(n-1)+(n-3)+\cdots+2=\frac{n^{2}-1}{4}, \\
\text { if } n \text { is odd. }
\end{array}\right. \\
\end{array}
$$

On the other hand, we can divide the $n$ points into two groups: when $n$ is even, each group has $\frac{n}{2}$ points; when $n$ is odd, one group has $\frac{n-1}{2}$ points and the other has $\frac{n+1}{2}$ points. By connecting each point in the first group to each point in the second group, we can form $\frac{n^{2}}{4}$ or $\frac{n^{2}-1}{4}$ lines, and these lines do not intersect to form a triangle with all three vertices being the given points.
Thus, $k_{\max }=\left\{\begin{array}{ll}\frac{n^{2}}{4}, & \text { if } n \text { is even; } \\ \frac{n^{2}-1}{4}, & \text { if } n \text { is odd. }\end{array}\right.$