Let $a_1,a_2,\ldots,a_n$ be a permutation of the numbers $1,2,\ldots,n$, with $n\geq 2$. Determine the largest possible value of the sum \[ S(n)=|a_2-a_1|+ |a_3-a_2| + \cdots + |a_n-a_{n-1}| . \]
[i]Romania[/i]
To determine the largest possible value of the sum 
\[ S(n) = |a_2 - a_1| + |a_3 - a_2| + \cdots + |a_n - a_{n-1}|, \]
we need to consider the arrangement of the permutation \(a_1, a_2, \ldots, a_n\) that maximizes the sum of the absolute differences between consecutive terms.

1. **Understanding the Problem:**
   - We are given a permutation of the numbers \(1, 2, \ldots, n\).
   - We need to maximize the sum of the absolute differences between consecutive terms in this permutation.

2. **Strategy for Maximization:**
   - To maximize the sum of absolute differences, we should place the numbers in such a way that the difference between consecutive terms is as large as possible.
   - This can be achieved by alternating between the largest and smallest remaining numbers.

3. **Constructing the Permutation:**
   - For an odd \(n\), we can arrange the numbers as follows:
     \[
     \left(\frac{n+1}{2}, n, 1, n-1, 2, n-2, \ldots, \frac{n+1}{2} + 1\right)
     \]
   - For an even \(n\), we can arrange the numbers as follows:
     \[
     \left(\frac{n}{2}, n, 1, n-1, 2, n-2, \ldots, \frac{n}{2} + 1\right)
     \]

4. **Calculating the Sum \(S(n)\):**
   - For both odd and even \(n\), the sum \(S(n)\) can be calculated by summing the absolute differences between consecutive terms in the constructed permutation.

5. **Example Calculation:**
   - For \(n = 5\) (odd):
     \[
     \left(3, 5, 1, 4, 2\right)
     \]
     \[
     S(5) = |5 - 3| + |1 - 5| + |4 - 1| + |2 - 4| = 2 + 4 + 3 + 2 = 11
     \]
   - For \(n = 4\) (even):
     \[
     \left(2, 4, 1, 3\right)
     \]
     \[
     S(4) = |4 - 2| + |1 - 4| + |3 - 1| = 2 + 3 + 2 = 7
     \]

6. **General Formula:**
   - The general formula for the maximum sum \(S(n)\) is:
     \[
     S(n) = \left\lfloor \frac{n^2}{2} \right\rfloor - 1
     \]

The final answer is \( \boxed{ \left\lfloor \frac{n^2}{2} \right\rfloor - 1 } \).