I have a vector $\mathbf{A}=\begin{bmatrix}a_1&a_2&a_3\end{bmatrix}$ where $a_i$ is a Bernoulli RV with PMF, $$p(a_i)=\begin{cases} \frac{1}{2} & \text{if } a_i = 1\\ \frac{1}{2} & \text{if } a_i = -1. \end{cases}$$
I need to autocorrelate $\mathbf{A}$ to yield, $$\mathbf{A_x}=\begin{bmatrix}a_1a_3&a_1a_2+a_2a_3&a_1a_1+a_2a_2+a_3a_3&a_2a_1+a_3a_2&a_3a_1\end{bmatrix}.$$
Empirically, I get two occurences of $\mathbf{A_x}=\begin{bmatrix}1&2&3&2&1\end{bmatrix}$, four occurrences of $\mathbf{A_x}=\begin{bmatrix}-1&0&3&0&-1\end{bmatrix}$ and two occurrences of $\mathbf{A_x}=\begin{bmatrix}1&-2&3&-2&1\end{bmatrix}$.
I am looking to develop a general formula which can then be extended to longer vectors $\mathbf{A}$. Would appreicate any pointers or tips on how to generalize for the case where $\mathbf{A}$ contains three elements.