Let $n$ be a positive integer. Alice writes $n$ real numbers $a_1, a_2,\dots, a_n$ in a line (in that order). Every move, she picks one number and replaces it with the average of itself and its neighbors ($a_n$ is not a neighbor of $a_1$, nor vice versa). A number [i]changes sign[/i] if it changes from being nonnegative to negative or vice versa. In terms of $n$, determine the maximum number of times that $a_1$ can change sign, across all possible values of $a_1,a_2,\dots, a_n$ and all possible sequences of moves Alice may make.
1. **Construction**: We need to show that $a_1$ can change sign $n-1$ times. Consider the sequence $a_i = (-100000n)^i$ for $i = 1, 2, \ldots, n$. Initially, $a_2$ has the "baton" (i.e., it is the number that will be used to influence $a_1$). When Alice performs the operation on $a_1$, it changes sign because $a_1$ is replaced by the average of itself and $a_2$. This process continues, passing the baton to $a_3$, then $a_2$, and so on. Each time the baton is passed to $a_1$, $a_1$ changes sign. This construction ensures that $a_1$ changes sign $n-1$ times.

2. **Proof of Bound**: Let $t$ be the largest number such that $a_1, a_2, \ldots, a_t$ have the same (nonzero) sign. We claim that $a_1$ can only change sign $n-t$ times. To prove this, we need to show that when $a_1$ changes sign, $a_1, a_2, \ldots, a_{t+1}$ have the same sign. 

   - Assume without loss of generality that $a_1$ is initially positive. For $a_1$ to change sign, $a_2$ must be negative. This implies that $a_3$ must also be negative, and so on, up to $a_t$.
   - When $a_1$ changes sign, it becomes negative, and $a_1, a_2, \ldots, a_{t+1}$ all have the same sign (negative in this case).

3. **Conclusion**: Since $t$ can be any value from $1$ to $n-1$, the maximum number of times $a_1$ can change sign is $n-1$.

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