There are $2n-1$ lamps in a row. In the beginning only the middle one is on (the $n$-th one), and the other ones are off. Allowed move is to take two non-adjacent lamps which are turned off such that all lamps between them are turned on and switch all of their states from on to off and vice versa. What is the maximal number of moves until the process terminates?
1. **Initial Configuration**: We start with a string of $2n-1$ lamps, where the middle lamp (the $n$-th lamp) is on, and all other lamps are off. This can be represented as:
   \[
   0, 0, \ldots, 0, 1, 0, \ldots, 0, 0
   \]
   where there are $n-1$ zeros on each side of the single 1.

2. **Allowed Move**: The allowed move is to select a substring of length $L \geq 3$ that starts and ends with a zero and has all ones in between. For example, a substring of the form $0, 1, 1, \ldots, 1, 0$. When this substring is selected, it is flipped to $1, 0, 0, \ldots, 0, 1$.

3. **First Move**: In the initial configuration, the only possible move is to select the entire string, which is of length $2n-1$. This string starts and ends with a zero and has $2n-3$ ones in between. Flipping this string, we get:
   \[
   1, 0, 0, \ldots, 0, 1
   \]
   Now, the first and last lamps are on, and all other lamps are off.

4. **Subsequent Moves**: After the first move, we need to consider the new configuration. The next possible moves will involve selecting substrings that fit the allowed move criteria. Each move will reduce the number of ones in the string by 2 and increase the number of zeros by 2.

5. **General Pattern**: Each move reduces the number of ones by 2. Initially, there are $2n-3$ ones. The process continues until there are no more ones left that can be flipped. The number of moves required to reduce the number of ones from $2n-3$ to 0 is:
   \[
   \frac{2n-3}{2} = n - \frac{3}{2}
   \]
   Since the number of moves must be an integer, we take the floor function:
   \[
   \left\lfloor n - \frac{3}{2} \right\rfloor = n - 1
   \]

6. **Conclusion**: The maximal number of moves until the process terminates is $n-1$.

The final answer is $\boxed{n-1}$.