Let $n \geq 3$ be an integer. A sequence $P_1, P_2, \ldots, P_n$ of distinct points in the plane is called [i]good[/i] if no three of them are collinear, the polyline $P_1P_2 \ldots P_n$ is non-self-intersecting and the triangle $P_iP_{i + 1}P_{i + 2}$ is oriented counterclockwise for every $i = 1, 2, \ldots, n - 2$.
For every integer $n \geq 3$ determine the greatest possible integer $k$ with the following property: there exist $n$ distinct points $A_1, A_2, \ldots, A_n$ in the plane for which there are $k$ distinct permutations $\sigma : \{1, 2, \ldots, n\} \to \{1, 2, \ldots, n\}$ such that $A_{\sigma(1)}, A_{\sigma(2)}, \ldots, A_{\sigma(n)}$ is good.
(A polyline $P_1P_2 \ldots P_n$ consists of the segments $P_1P_2, P_2P_3, \ldots, P_{n - 1}P_n$.)
1. **Understanding the Problem:**
   We need to determine the greatest possible integer \( k \) such that there exist \( n \) distinct points \( A_1, A_2, \ldots, A_n \) in the plane for which there are \( k \) distinct permutations \( \sigma : \{1, 2, \ldots, n\} \to \{1, 2, \ldots, n\} \) such that \( A_{\sigma(1)}, A_{\sigma(2)}, \ldots, A_{\sigma(n)} \) is a good sequence.

2. **Convex Hull and Good Sequence:**
   Let \( \mathcal{H} = \{H_1, H_2, \ldots, H_k\} \) be the convex hull of the points, with the points \( H_1, H_2, \ldots, H_k \) on \( \mathcal{H} \) in counterclockwise order. A good sequence cannot leave the convex hull and return to it, as this would violate the non-self-intersecting condition.

3. **Claim 1: No Subsequence of the Form \( H_iQ_1\cdots Q_kH_j \):**
   Assume for contradiction that there is a subsequence of the form \( H_iQ_1\cdots Q_kH_j \), where \( Q_1, \ldots, Q_k \notin \mathcal{H} \). This would imply that we are trapped in the region defined by segments \( H_iQ_1, Q_1Q_2, \ldots, Q_kH_j \) and the rays \( H_{i-1}H_i, H_{j+1}H_j \). Thus, we cannot reach \( H_t \) for \( t \notin \{i, i+1, \ldots, j\} \), leading to a contradiction.

4. **Claim 2: Line Intersecting Segment \( H_tH_{t-1} \) Divides \( \mathcal{A} \) and \( \mathcal{B} \):**
   Let \( \mathcal{A} = \{A_i, \ldots, A_1\} \) and \( \mathcal{B} = \{B_1, \ldots, B_j\} \). There is a line intersecting segment \( H_tH_{t-1} \) that divides \( \mathcal{A} \) and \( \mathcal{B} \). This is because \( \mathcal{A} \) is always on one side of \( \overline{H_tA_1} \) and \( \mathcal{B} \) is always on one side of \( \overline{H_{t-1}B_1} \).

5. **Claim 3: Choice of \( t, \mathcal{A}, \mathcal{B} \) Uniquely Determines the Polyline:**
   For convenience, let \( A_0 = H_t \). For \( \ell \ge 0 \), the line \( A_\ell A_{\ell+1} \) splits the plane into two half-planes, one of which contains \( A_\ell, A_{\ell+1}, \ldots, A_i \). Thus, \( A_\ell \) uniquely determines \( A_{\ell+1} \) for \( \ell \ge 0 \), so \( A_1, \ldots, A_i \) are determined. Similarly, \( B_1, \ldots, B_j \) are determined.

6. **Counting the Number of Partitioners:**
   Let \( \mathcal{G} \) be the set of points in the polyline not in \( \mathcal{H} \), so \( |\mathcal{G}| = n - k \). Let there be \( v_t \) points on \( \overline{H_tH_{t-1}} \) that lie on line \( UV \) for some \( U, V \in \mathcal{G} \). A \( t \)-partitioner is a line through \( \overline{H_tH_{t-1}} \) partitioning \( \mathcal{G} \) into two sets.

7. **Number of \( t \)-Partitioners:**
   The number of \( t \)-partitioners is \( n - k + 1 + v_t \). Initially, there are \( n - k + 1 \) different partitioners through \( M \). For each \( U, V \in \mathcal{G} \) such that line \( UV \) intersects \( \overline{H_tH_{t-1}} \), the number of partitioners is incremented by \( v_t \).

8. **Total Number of Partitioners:**
   The total number of partitioners is:
   \[
   \sum_{t=1}^k (n - k + 1 + v_t) = k(n - k + 1) + 2\binom{n - k}{2}
   \]
   This expression is strictly decreasing, so it is maximized at \( k = 3 \).

9. **Final Calculation:**
   Substituting \( k = 3 \) into the expression, we get:
   \[
   k(n - k + 1) + 2\binom{n - k}{2} = 3(n - 3 + 1) + 2\binom{n - 3}{2} = 3(n - 2) + 2\frac{(n - 3)(n - 4)}{2} = 3n - 6 + (n - 3)(n - 4)
   \]
   Simplifying further:
   \[
   3n - 6 + n^2 - 7n + 12 = n^2 - 4n + 6
   \]

The final answer is \(\boxed{n^2 - 4n + 6}\).