# Probability to complete a sequence with two attempts

Imagine a slot machine with $N$ reels.

I want to calculate the probability $P$ that a player hits a certain sequence $A$, if the player has given the possibility to spin again (and only once again), keeping the symbols belonging to $A$ (if any has come out).

No problem with only one spin:

$$P(A) = \prod_{n=1}^NP(a_n)$$

where $P(a_n)$ is the probability that a symbol belonging to $A$ comes out on the reel $n$ (with $a_n$ potentially different from $a_{n+1}$).

But how to introduce the second spin into the calculation?

$$\mathbb{P}(A) = \prod\limits_{n=1}^{N}P(a_n) + (1-P(a_n))P(a_n) = \prod\limits_{n=1}^{N} 2P(a_n) - P(a_n)^2$$
Because for each wheel, either we succeed in the first attempt (with probability $P(a_n)$) or we fail (with probability $1-P(a_n)$) and then succeed in the second attempt (with probability $P(a_n)$).