Solution:
The maximum number is n−1. We first prove the upper bound. For simplicity, color all negative numbers red, and all non-negative numbers blue. Let X be the number of color changes among adjacent elements (i.e. pairs of adjacent elements with different colors). It is clear that the following two statements are true:
(1) When a1 changes sign, X decreases by 1. If a1 changes from negative (red) to non-negative (blue), a2 must have been non-negative (blue), so the first two colors changed from RB to BB. The same applies when a1 changes from non-negative to negative.
(2) X cannot increase after a move. Suppose Alice picks ai for her move where 1≤i≤n. If ai does not change sign, then X clearly remains the same. Else, if ai changes sign and i=1 or n, then X decreases by 1 (from (1)). Finally, if ai changes sign and i=1,n, we have two cases:
Case 1: ai−1,ai+1 are of the same color. If they are both negative (red), then if ai changes color, it must be from non-negative to negative (blue to red). Thus, the colors change from RBR to RRR and X decreases by 2. The same holds if both ai−1,ai+1 are non-negative.
Case 2: ai−1,ai+1 are of different colors. No matter what the color of ai is, there is exactly one color change among the three numbers, so X will remain the same.
Now, since the initial value of X is at most n−1, it can decrease by 1 at most n−1 times. Hence, a1 can change signs at most n−1 times.
Now we prove the lower bound by constructing such a sequence inductively. Specifically, we induct on the following statement:
For every n≥2, there exists a sequence a1,a2,⋯,an such that by picking
a1,a2,a1,a3,a2,a1,⋯,an−1,an−2,⋯,a2,a1
in that order, a1 changes sign n−1 times.
When n=2, we can let a1 change sign once by starting with the sequence (1,−3), and picking a1 to obtain (−1,−3), which satisfies the conditions in our statement.
Suppose we have proven the statement for n−1. For n, let a1,a2,⋯,an−1 be as defined in our construction for n−1 (we shall fix the value of an later). After executing the steps a1,a2,a1,a3,a2,a1,⋯,an−2,an−3,⋯,a2,a1, a1 would have changed sign n−2 times.
It now remains to pick an−1,an−2,⋯,a2,a1 in order so that a1 changes sign one more time. This is always possible as long as an is sufficiently large in magnitude and of the opposite sign as a1. Since the value of an has remained unchanged since the start (as we have not picked an at all), it suffices to let an be a number satisfying the above conditions at the start.
This completes our induction, and we conclude that the maximum number of times that a1 can change sign is n−1.