All this to say that the current bit is different from the next bit
Since we’re considering the current bit and its next bit, we don’t consider the last bit since there’s no bit after the last bit
This means we have n-1 pairs
$ \mathbb{E}(X) = \sum_{i=1}^{n-1} 1 \cdot Pr(A) $
$ \mathbb{E}(X) = (n-1) \cdot \frac{1}{2} $
$ \mathbb{E}(X) = \frac{n-1}{2} $
The expected value of X is $ \frac{n-1}{2} $